-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (27 loc) · 876 Bytes
/
Dockerfile
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
# Stage 1: Build
# Use an official Node.js runtime as a parent image
FROM node:20-alpine as builder
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy package.json and package-lock.json for installing dependencies
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
RUN npm run build
# Stage 2: Runtime
# Use an official Node.js runtime as a parent image for the runtime stage
FROM node:20-alpine
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy built assets from the builder stage
COPY --from=builder /usr/src/app/dist ./dist
COPY package*.json ./
RUN npm ci --only=production
# Use a non-root user to run the application for security purposes
USER node
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application
CMD ["node", "dist/app.js"]