-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (47 loc) · 1.35 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
#
# Stage 1: build
#
FROM node:16.15.0-alpine@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10 AS build
USER node
ARG CI=true
WORKDIR /home/node
COPY --chown=node:node ["package.json", "package-lock.json", "./"]
RUN npm ci
COPY --chown=node:node . .
RUN npm run build
#
# Stage 2: clean
#
FROM node:16.15.0-alpine@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10 AS clean
USER node
ARG CI=true
WORKDIR /home/node
COPY --chown=node:node ["package.json", "package-lock.json", "./"]
RUN npm ci --only=production
#
# Stage 3: production
#
FROM node:16.15.0-alpine@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10
ARG USERNAME=nonroot
ARG USERHOME=/home/${USERNAME}
ENV NODE_ENV="production"
ENV SERVICE_NAME="Data Access Patterns"
ENV SQLITE_DB_PATH=":memory:"
RUN deluser --remove-home node && \
addgroup \
--gid 1000 \
${USERNAME} \
&& \
adduser \
--disabled-password \
--home ${USERHOME} \
--ingroup ${USERNAME} \
--uid 1000 \
${USERNAME}
RUN apk update && apk add --no-cache tini
COPY --from=build --chown=${USERNAME}:${USERNAME} /home/node/dist ${USERHOME}/src
COPY --from=clean --chown=${USERNAME}:${USERNAME} /home/node/node_modules ${USERHOME}/node_modules
WORKDIR ${USERHOME}
USER ${USERNAME}
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "src/Main"]