-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
29 lines (26 loc) · 878 Bytes
/
Dockerfile
File metadata and controls
29 lines (26 loc) · 878 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
### Stage 0 - Base image
FROM node:20.12.1-alpine as base
WORKDIR /app
RUN apk --no-cache update && \
apk --no-cache upgrade && \
apk add --no-cache --virtual .build-dependencies python3 make g++
### Stage 1 - Cached node_modules image
FROM base as dependencies
COPY package.json .
COPY package-lock.json .
RUN NODE_ENV=production npm install && mv node_modules node_modules_production
RUN NODE_ENV=development npm install && mv node_modules node_modules_development
### Stage 2 - Development image
FROM base as development
ENV NODE_ENV=development
COPY --from=dependencies /app/node_modules_development ./node_modules
COPY . .
USER nobody
CMD ["node", "lib/index.js"]
### Stage 3 - Production image
FROM base as production
ENV NODE_ENV=production
COPY --from=dependencies /app/node_modules_production ./node_modules
COPY . .
USER nobody
CMD ["node", "lib/index.js"]