-
Notifications
You must be signed in to change notification settings - Fork 153
/
Dockerfile
62 lines (46 loc) · 1.74 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
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.0-alpine3.17 as production
RUN apk --no-cache --quiet add \
bash \
dumb-init \
&& adduser -D -g '' deploy
WORKDIR /app
RUN chown deploy:deploy $(pwd)
USER deploy
# Production node modules.
COPY --chown=deploy:deploy --from=builder-base /opt/node_modules.prod ./node_modules
# Base code
COPY --chown=deploy:deploy --from=builder-base /app/data ./data
COPY --chown=deploy:deploy --from=builder-base /app/dist ./dist
COPY --chown=deploy:deploy --from=builder-base /app/src ./src
COPY --chown=deploy:deploy --from=builder-base /app/scripts ./scripts
COPY --chown=deploy:deploy --from=builder-base /app/package.json .
COPY --chown=deploy:deploy --from=builder-base /app/yarn.lock .
ENTRYPOINT ["/usr/bin/dumb-init", "./scripts/load_secrets_and_run.sh"]
ENV NODE_PATH=/app/src
# TODO: Reduce production memory, this is not a concern
CMD ["node", "--max_old_space_size=2048", "--heapsnapshot-signal=SIGUSR2", "--no-experimental-fetch", "-r @swc-node/register", "./src/prod.ts"]