-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
37 lines (35 loc) · 1.36 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
# per https://github.com/node-gfx/node-canvas-prebuilt/issues/77#issuecomment-1975794256
FROM node:20-alpine AS build
RUN apk add --no-cache make gcc g++ python3 pkgconfig pixman-dev cairo-dev pango-dev libjpeg-turbo-dev
WORKDIR /app
COPY package*.json tsconfig.json ./
RUN npm ci
# Copy over src/other files
COPY ./src ./src
COPY ./fonts ./fonts
COPY ./images ./images
COPY ./wiki ./wiki
# Build the project, then re-install only runtime dependencies
RUN npm run build \
&& npm ci --omit=dev
# - - - FRESH BUILD STAGE - - -
FROM node:20-alpine as deploy
ENV NEW_RELIC_NO_CONFIG_FILE=true
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
ENV NEW_RELIC_LOG=stdout
## These are runtime dependencies required by node-canvas
RUN apk add --no-cache cairo pango libjpeg-turbo
WORKDIR /home/node/app
# Set user 'node' as the owner for all copied files
COPY --chown=node:node --from=build /app/build ./build
COPY --chown=node:node --from=build /app/node_modules ./node_modules
COPY --chown=node:node package*.json *.config.js ./
COPY --chown=node:node --from=build /app/fonts ./fonts
COPY --chown=node:node --from=build /app/images ./images
COPY --chown=node:node --from=build /app/wiki ./wiki
RUN npm install -g pm2
# Set 'node' as owner of this directory (permits creating files eg. logs)
RUN chown -h node:node .
USER node
# Start the application
CMD ["pm2-runtime", "ecosystem.config.js"]