-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
76 lines (49 loc) · 1.58 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# --- Builder --- #
FROM node:20-alpine as builder
ENV NODE_ENV build
USER node
WORKDIR /home/node
RUN npm config set proxy $http_proxy
RUN npm config set https-proxy $https_proxy
COPY package*.json ./
RUN npm ci
COPY --chown=node:node . .
# Build the application
RUN npm run build
# --- Only prod dependencies --- #
FROM builder as prod
# Remove dev dependencies
RUN npm prune --production
# Check the contents of the dist directory in the prod stage
RUN ls -al /home/node/dist
# --- Base final image with only shared dist content --- #
FROM node:20-alpine as shared
ENV NODE_ENV production
USER node
WORKDIR /home/node
COPY --from=prod --chown=node:node /home/node/package*.json ./
COPY --from=prod --chown=node:node /home/node/node_modules/ ./node_modules/
COPY --from=prod --chown=node:node /home/node/dist/shared ./dist/shared
# --- Base final image with batch dist content --- #
FROM shared as batch
USER node
COPY --from=prod --chown=node:node /home/node/dist/batch ./dist/batch
COPY --chown=node:node batch_docker_entrypoint.sh batch_docker_entrypoint.sh
ENTRYPOINT ["/bin/sh", "batch_docker_entrypoint.sh"]
# --- Base final image with api dist content --- #
FROM shared as api
USER node
WORKDIR /home/node
COPY --from=prod --chown=node:node /home/node/dist ./dist
CMD ["node", "dist/api/main"]
# --- Base image with batch content --- #
FROM shared as batch-local
USER node
CMD ["npm", "run", "batch:start:watch"]
# --- Base image with api content --- #
FROM node:20-alpine as api-local
USER node
WORKDIR /home/node
COPY --chown=node:node . .
RUN npm i
CMD ["npm", "run", "start:dev"]