-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (31 loc) · 1.06 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
# base environment
FROM node:16.19.0-alpine3.17 as base-stage
RUN mkdir /app && chown -R node:node /app
RUN apk add python3 --no-cache
WORKDIR /app
USER node
# dependency environment
FROM base-stage as dependency-stage
COPY --link --chown=1000:1000 package*.json ./
RUN npm ci
# prebuild stage to stop at for testing
FROM dependency-stage as prebuild-stage
COPY --link --chown=1000:1000 . .
# build environment
FROM prebuild-stage as build-stage
RUN npm run build
# prod dependency environment
FROM dependency-stage as production-dependency-stage
RUN npm prune --production
# production environment
FROM alpine:3.17.0 as production-stage
WORKDIR /app
RUN apk add --no-cache libstdc++ tini \
&& addgroup -g 1000 node && adduser -u 1000 -G node -s /bin/sh -D node \
&& chown node:node ./
COPY --from=base-stage /usr/local/bin/node /usr/local/bin/
USER node
COPY --link --chown=1000:1000 --from=production-dependency-stage /app/node_modules node_modules
COPY --link --chown=1000:1000 --from=build-stage /app/dist .
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "/app/main.js"]