-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerFile
More file actions
38 lines (27 loc) · 946 Bytes
/
DockerFile
File metadata and controls
38 lines (27 loc) · 946 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
# 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 the package.json and package-lock.json (if available)
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Install serve to run the application in production
RUN npm install -g serve
# Use a smaller image for the final stage
FROM node:18-alpine AS runner
# Set the working directory in the container
WORKDIR /app
# Copy the build files and node_modules from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application
CMD ["npm", "run", "start"]