-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (35 loc) · 1.04 KB
/
Dockerfile
File metadata and controls
50 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Build stage
FROM node:20-slim AS builder
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
# Install all dependencies
RUN pnpm install --frozen-lockfile
# Copy the rest of the application
COPY . .
# Build the application
RUN pnpm run build
# Production stage
FROM node:20-slim AS runner
# Set working directory
WORKDIR /app
# Set environment to production
ENV NODE_ENV=production
# Install pnpm and pm2
RUN npm install -g pnpm pm2
# Copy package files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
# Install ONLY production dependencies
RUN pnpm install --prod --frozen-lockfile
# Copy the built application and necessary files
COPY --from=builder /app/build ./build
COPY --from=builder /app/public ./public
COPY --from=builder /app/ecosystem.config.js ./
COPY --from=builder /app/package.json ./
# Expose the application port
EXPOSE 5500
# Start the application using PM2 runtime
CMD ["pm2-runtime", "start", "ecosystem.config.js"]