-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (28 loc) · 793 Bytes
/
Copy pathDockerfile
File metadata and controls
42 lines (28 loc) · 793 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
37
38
39
40
41
42
# ---------- Build Stage ----------
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files first for better caching
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build Next.js app
RUN npm run build
# ---------- Production Stage ----------
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copy package files
COPY --from=builder /app/package*.json ./
# Install production dependencies only
RUN npm ci --omit=dev
# Copy built app
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
# If using App Router, Next.js may also need these files
COPY --from=builder /app/next.config.* ./
COPY --from=builder /app/package.json ./
EXPOSE 3000
CMD ["npm", "start"]