-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
39 lines (28 loc) · 811 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
38
39
# Build stage
FROM node:20-alpine3.16 AS builder
WORKDIR /app
## Copy package files and install dependencies
COPY package*.json ./
RUN npm install
## Copy other necessary files
COPY tsconfig.json .
COPY ecosystem.config.js .
COPY .env.production .
COPY ./src ./src
## Build the application
RUN npm run build
# Start stage
FROM node:20-alpine3.16
WORKDIR /app
## Install Python and PM2 globally
RUN apk add --no-cache python3 && \
npm install pm2 -g
#3 Create a non-root user and switch to it
RUN adduser -D appuser
## Copy built artifacts and other necessary files from the builder stage
COPY --from=builder /app .
RUN chown -R appuser:appuser /app
## Expose the port the app runs on
EXPOSE 4000
## Command to run the app
CMD ["pm2-runtime", "start", "ecosystem.config.js", "--env", "production"]