-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
35 lines (26 loc) · 764 Bytes
/
dockerfile
File metadata and controls
35 lines (26 loc) · 764 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
# ---------- 1. Build stage ----------
FROM node:20-alpine AS builder
WORKDIR /app
# Copy only the dependency manifests first for caching
COPY package*.json ./
# Install all dependencies
RUN npm install
# Copy the rest of the source code
COPY . .
# Build the Next.js app
RUN npm run build
# ---------- 2. Production stage ----------
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Disable Next telemetry in containers
ENV NEXT_TELEMETRY_DISABLED=1
# Copy the build output from the builder image
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# Install only production deps
RUN npm install --omit=dev
# Expose port 3000 and run
EXPOSE 3000
CMD ["npm", "start"]