-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (26 loc) · 863 Bytes
/
Dockerfile
File metadata and controls
36 lines (26 loc) · 863 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: The `builder` stage for building the Next.js app
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files first (cached)
COPY package.json package-lock.json ./
# Install all dependencies (including dev deps)
RUN npm install
# Copy the rest of the source code
COPY . .
# Build the Next.js app
RUN npm run build
# Stage 2: The `runner` stage for running the production server
FROM node:18-alpine AS runner
# Set working directory
WORKDIR /app
# Set environment variables for production
ENV NODE_ENV production
EXPOSE 3000
# Copy only the necessary files from builder
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Start the Next.js production server
CMD ["npm", "start"]