-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (25 loc) · 728 Bytes
/
Dockerfile
File metadata and controls
35 lines (25 loc) · 728 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
# Use an official Node.js runtime as a parent image
FROM node:18 AS builder
# Set the working directory
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm install
# Copy the entire project
COPY . .
# Build the Next.js application
RUN npm run build
# Use a smaller image for the final build
FROM node:18-slim
# Set the working directory
WORKDIR /app
# Copy the build artifacts from the builder stage
COPY --from=builder /app/.next .next
COPY --from=builder /app/public public
COPY --from=builder /app/package.json /app/package-lock.json ./
# Install production dependencies
RUN npm install --only=production
# Expose port
EXPOSE 3000
# Start the Next.js application
CMD ["npm", "start"]