-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdockerfile
More file actions
36 lines (26 loc) · 761 Bytes
/
Copy pathdockerfile
File metadata and controls
36 lines (26 loc) · 761 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
# Step 1: Build the app
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Install dependencies
COPY package.json ./
RUN npm install
# Copy the rest of the project files
COPY . .
# Build the Next.js app
RUN npm run build
# Step 2: Production image
FROM node:18-alpine AS runner
# Set working directory
WORKDIR /app
# Copy the build files from the builder stage
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/package.json ./
COPY --from=builder /app/public ./public
# Install only production dependencies (optional)
RUN npm install --only=production
# Expose the port that Next.js will run on
EXPOSE 3000
# Start the Next.js app
CMD ["npm", "run", "start"]