-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (24 loc) · 855 Bytes
/
Dockerfile
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
# Stage 1: Build the Next.js app
FROM node:18 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the package.json and package-lock.json to the container
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the app source code to the container
COPY . .
# Build the Next.js app
RUN npm run build
# Stage 2: Serve the app using a lightweight production image
FROM node:18-alpine
# Set the working directory inside the container
WORKDIR /app
# Copy the built app from the previous stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Expose the port on which your Next.js app will run (change this to your app's port)
EXPOSE 3000
# Start the Next.js app in production mode
CMD ["npm", "start"]