-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
51 lines (38 loc) · 1.4 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
# =============================================================================
# Target: "base"
FROM node:16-alpine
# Upgrade system packages and install runtime dependencies.
RUN apk --no-cache --update upgrade \
&& apk --no-cache add \
ca-certificates \
&& rm -rf /var/cache/apk/*
# To overcome permission issues when installing global deps: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#global-npm-dependencies
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
# Setup the application user and group
RUN addgroup -Sg 40023 waam && \
adduser -Su 40023 -G waam waam && \
install -d -o waam -g waam /usr/src/app
# Subsequent commands run relative to this directory.
WORKDIR /usr/src/app
RUN chown -Rh waam:waam /home/node
# Subsequent commands run as this non-root user.
USER waam
# Install Yarn
RUN npm i -g corepack
# Install server dependencies.
COPY --chown=waam package.json ./
COPY --chown=waam yarn.lock ./
RUN yarn install
# Install client dependencies.
COPY --chown=waam ./client/package.json ./client/
COPY --chown=waam ./client/yarn.lock ./client/
RUN cd /usr/src/app/client && yarn install
# Build the client.
COPY --chown=waam ./client/ ./client/
RUN cd /usr/src/app/client && yarn run build
# Copy the rest of the codebase.
COPY --chown=waam . .
# Set node as the entrypoint.
ENTRYPOINT ["npm"]
# The default command runs the server.
CMD ["run", "server"]