-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (26 loc) · 886 Bytes
/
Dockerfile
File metadata and controls
37 lines (26 loc) · 886 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
37
# Use an official Node.js runtime as a parent image
FROM node:18-alpine AS builder
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the Next.js application source code
COPY . .
# Build the Next.js application for production
RUN npm run build
# Production image, copy all the files and configurations we need
FROM node:18-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# You only need to copy next.config.js if you have one
COPY --from=builder /app/next.config.js ./
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 listens on
EXPOSE 3000
# Start the Next.js server
CMD ["npm", "start"]