-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
36 lines (29 loc) · 888 Bytes
/
dockerfile
File metadata and controls
36 lines (29 loc) · 888 Bytes
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
# ---------------------------
# Stage 1: Dependencies
# ---------------------------
FROM node:20-alpine AS deps
WORKDIR /app
# Install dependencies only (cached separately)
COPY package.json package-lock.json* yarn.lock* pnpm-lock.yaml* ./
RUN npm ci || npm install
# ---------------------------
# Stage 2: Builder
# ---------------------------
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# ---------------------------
# Stage 3: Production runner
# ---------------------------
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Copy only the files needed at runtime
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
CMD ["npm", "start"]