-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (33 loc) · 1.25 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
################################################################################
# Builder
################################################################################
FROM node:20-alpine AS builder
RUN apk add --no-cache g++ make python3
RUN NPM_CONFIG_UPDATE_NOTIFIER=false npm i -g json
COPY package.json pnpm-lock.yaml /opt/app/
WORKDIR /opt/app
RUN corepack enable
RUN pnpm install --frozen-lockfile
RUN mkdir out \
&& cat package.json \
| json -q -e 'this.scripts = { "typeorm": "typeorm -d src/db.js", "start": "node index.js" }; delete this.devDependencies' \
| tee out/package.json >/dev/null \
&& cp pnpm-lock.yaml out/ \
&& cd out \
&& pnpm install --no-optional --prefer-offline --prod
COPY . /opt/app/
RUN pnpm run build:compile --silent
################################################################################
# Target
################################################################################
FROM node:20-alpine
RUN apk add --no-cache imagemagick graphicsmagick tini
COPY --from=builder /opt/app/out/ /opt/app/
WORKDIR /opt/app
RUN mkdir -p /config \
&& chown node:nobody /config \
&& chmod 2770 /config \
&& ln -s /config /opt/app/config
VOLUME /config
USER node
ENTRYPOINT ["/sbin/tini", "--", "node", "--no-warnings", "index.js"]