-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (29 loc) · 1019 Bytes
/
Copy pathDockerfile
File metadata and controls
42 lines (29 loc) · 1019 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
41
42
# Use the official Node.js 18-alpine image as the base image for the build stage
FROM node:18-alpine AS build
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the application code to the container
COPY . .
# Build the Next.js app
RUN npm run build
# Use the official Node.js 18-alpine image as the base image for the runtime stage
FROM node:18-alpine AS runtime
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy the built app from the build stage to the runtime stage
COPY --from=build /app/.next ./.next
# Copy the public folder from the build stage to the runtime stage
COPY --from=build /app/public ./public
# Expose port 3000
EXPOSE 3000
USER node
# Start the Next.js app
CMD ["npm", "start"]