This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathDockerfile.docs
74 lines (49 loc) · 1.89 KB
/
Dockerfile.docs
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
FROM node:15.9-alpine as build
ENV NODE_ENV=production
## Install build toolchain, install node deps and compile native add-ons
RUN apk --no-cache add python3 make g++
RUN mkdir -p /usr/src/app
RUN mkdir -p /usr/src/app/packages
WORKDIR /usr/src/app
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY docs ./docs
WORKDIR /usr/src/app/docs
RUN yarn install --production=false --pure-lockfile --non-interactive --network-timeout 100000
RUN yarn build
FROM node:15.9-alpine as app
ARG NEW_RELIC_APP_NAME=DesignSystemDocs::Production
ENV NEW_RELIC_APP_NAME $NEW_RELIC_APP_NAME
ARG NEW_RELIC_ENABLED=true
ENV NEW_RELIC_ENABLED $NEW_RELIC_ENABLED
ENV NEW_RELIC_LICENSE_KEY $NEW_RELIC_LICENSE_KEY
ENV NODE_ENV=production
ARG HOST=0.0.0.0
ENV HOST $HOST
ARG PORT=3000
ENV PORT $PORT
ENV TZ=America/Denver
ARG LOG_LEVEL=info
ENV LOG_LEVEL $LOG_LEVEL
RUN mkdir -p /usr/src/app
RUN mkdir -p /usr/src/app/packages
WORKDIR /usr/src/app
COPY package.json .
COPY yarn.lock .
COPY tsconfig.json .
COPY --from=build /usr/src/app/package.json /usr/src/app/package.json
COPY --from=build /usr/src/app/yarn.lock /usr/src/app/yarn.lock
COPY --from=build /usr/src/app/docs/package.json /usr/src/app/docs/package.json
COPY --from=build /usr/src/app/docs/health-check.js /usr/src/app/docs/health-check.js
COPY --from=build /usr/src/app/docs/newrelic.js /usr/src/app/docs/newrelic.js
COPY --from=build /usr/src/app/docs/dist /usr/src/app/docs/dist
COPY --from=build /usr/src/app/docs/public /usr/src/app/docs/public
WORKDIR /usr/src/app/docs
RUN yarn install --pure-lockfile --non-interactive --production
# the official node image provides an unprivileged user as a security best practice
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user
USER node
HEALTHCHECK --interval=5s --timeout=30s --retries=3 \
CMD node /usr/src/app/docs/health-check.js
CMD ["node", "./dist/server/main.js"]