-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.prod
More file actions
40 lines (28 loc) · 934 Bytes
/
Dockerfile.prod
File metadata and controls
40 lines (28 loc) · 934 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
38
39
40
# Stage 1: Build
FROM node:alpine AS build
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock if you use yarn)
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Build the Next.js app
RUN npm run build
# Stage 2: Production
FROM node:alpine
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock if you use yarn) for production dependencies
COPY --from=build /app/package*.json ./
# Install only production dependencies and remove apk cache
RUN npm install --only=production \
&& rm -rf /var/cache/apk/*
# Copy the build directory from the build stage
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]