-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
46 lines (33 loc) · 1023 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
40
41
42
43
44
45
46
# image build
ARG NODE_VERSION
FROM node:14.15.1-alpine AS build
# hadolint ignore=DL3018
RUN apk --no-cache add ca-certificates curl
ENV HOME_DIR /app
RUN adduser -S -D -h ${HOME_DIR} appuser
WORKDIR ${HOME_DIR}
COPY --chown=appuser:nogroup . .
USER appuser
# Add npm registry credential
RUN npm ci
# generate build
RUN npm run build
# Install just required dependencies to be used on the next stage in a clean container
RUN npm ci --production
# Use multistage to create a small size image
FROM node:14.15.1-alpine
ENV HOME_DIR /app
ENV WHATAMI codemagic-build-monitor
ENV NODE_ENV production
ENV HTTP_PORT 9902
# hadolint ignore=DL3018
RUN apk --no-cache add ca-certificates
RUN adduser -S -D -h ${HOME_DIR} appuser
USER appuser
WORKDIR ${HOME_DIR}
COPY --from=build /app/node_modules/ ${HOME_DIR}/node_modules
COPY --from=build /app/dist/ ${HOME_DIR}/dist
COPY --from=build /app/package.json ${HOME_DIR}/package.json
COPY --from=build /app/docs/ ${HOME_DIR}/docs
EXPOSE 9902
CMD ["node", "dist/index.js"]