-
Notifications
You must be signed in to change notification settings - Fork 89
/
Dockerfile
57 lines (44 loc) · 1.5 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
# ---------------------------------------------------------
# Base build dependencies
# ---------------------------------------------------------
FROM node:18.15-alpine as builder-base
WORKDIR /app
RUN apk --no-cache --quiet add \
bash \
build-base \
dumb-init \
git
# Copy files required to install application dependencies
COPY package.json yarn.lock ./
COPY patches ./patches
# Install packages
RUN yarn install --production --frozen-lockfile --quiet && \
mv node_modules /opt/node_modules.prod && \
yarn install --frozen-lockfile --quiet && \
yarn cache clean --force
# Copy application code
COPY . ./
RUN yarn build
# ---------------------------------------------------------
# Release image
# ---------------------------------------------------------
#
# Release stage. This stage creates the final docker iamge that will be
# released. It contains only production dependencies and artifacts.
#
FROM node:18.15-alpine as production
WORKDIR /app
RUN apk --no-cache --quiet add \
bash \
dumb-init \
git \
&& adduser -D -g '' deploy
RUN chown deploy:deploy $(pwd)
# Switch to deploy user
USER deploy
COPY --chown=deploy:deploy --from=builder-base /app/.circleci ./.circleci
COPY --chown=deploy:deploy --from=builder-base /app/build ./build
COPY --chown=deploy:deploy --from=builder-base /app/src/data ./src/data
COPY --chown=deploy:deploy --from=builder-base /opt/node_modules.prod ./node_modules
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["node", "--heapsnapshot-signal=SIGUSR2", "build/index.js"]