-
Notifications
You must be signed in to change notification settings - Fork 398
/
Dockerfile
40 lines (29 loc) · 1.02 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
#
# Build
#
FROM node:18.20-slim AS builder
WORKDIR /srv/node
COPY package.json yarn.lock /srv/node/
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates git && rm -rf /var/lib/apt/lists/
RUN yarn install --pure-lockfile
#
# Install
#
FROM node:18.20-slim
ARG app_uid=9500
ARG app_dir=/app
RUN useradd -u ${app_uid} -d /home/app -m -s /sbin/nologin app
# The WORKDIR directive set the ownership of the work directory to root instead
# of USER unless the "buildkit" feature is enabled. To make sure the work
# directory is owned by the proper user for everybody, we manually set the
# ownership.
RUN mkdir -p ${app_dir} && chown ${app_uid}:${app_uid} ${app_dir}
USER ${app_uid}:${app_uid}
WORKDIR ${app_dir}
COPY --chown=${app_uid}:${app_uid} . ${app_dir}/
# Replace the local node_modules with the ones we installed above.
RUN rm -rf node_modules
COPY --from=builder --chown=${app_uid}:${app_uid} /srv/node/node_modules ${app_dir}/node_modules
ENV SERVER_HOST 0.0.0.0
ENV SERVER_PORT 4000
CMD yarn start