-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (24 loc) · 729 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (24 loc) · 729 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
# Stage 1: Build the application
FROM node:20 AS builder
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Create the final image
FROM node:20-alpine
# Set working directory
WORKDIR /app
# Copy only the necessary files from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
# Set the entrypoint or command if needed
# ENTRYPOINT ["node", "dist/index.js"]
# or if you use npm start
CMD ["npm", "start"]