-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (25 loc) · 851 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: Building the app
FROM node:20-alpine AS builder
# Set the working directory in the Docker container
WORKDIR /app
# Copy the package.json and package-lock.json (or yarn.lock) files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy the rest of your app's source code from your host to your image filesystem.
COPY . .
# Build the Next.js application
RUN npm run build
# Stage 3: Run the app in production mode
FROM node:20-alpine AS runner
WORKDIR /app
# Copy the build output from the builder stage
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
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 Next.js runs on
EXPOSE 3000
# Command to run the app
CMD ["npm", "start"]