-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
48 lines (39 loc) · 1.39 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
# -- compilation --
FROM node:22.12.0-alpine AS build
WORKDIR /app
# install dependencies
COPY package*.json ./
COPY backend/package*.json ./backend/
COPY frontend/package*.json ./frontend/
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
RUN apk add --no-cache --virtual .gyp python3 py-setuptools make g++ \
&& npm ci \
&& apk del .gyp
# copy in app code and build it
COPY . .
RUN npm run build
# -- execution --
FROM node:22.12.0-alpine
WORKDIR /app
RUN apk add --no-cache tini
# install production dependencies
COPY package*.json ./
COPY backend/package*.json ./backend/
COPY frontend/package*.json ./frontend/
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
RUN apk add --no-cache --virtual .gyp python3 py-setuptools make g++ \
&& npm ci --omit=dev --workspace=backend --include-workspace-root \
&& npm cache clean --force \
&& apk del .gyp
# add the already compiled code and the default config
# (custom config must be set via volume)
COPY --from=build /app/dist ./dist
COPY --from=build /app/backend/dist ./backend/dist
COPY --from=build /app/frontend/dist ./frontend/dist
# config
USER node
ENV PORT=8080
EXPOSE 8080
# use tini as init process since Node.js isn't designed to be run as PID 1
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "--enable-source-maps", "--disable-proto=delete", "dist/main.js"]