-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (36 loc) · 1.65 KB
/
Copy pathDockerfile
File metadata and controls
37 lines (36 loc) · 1.65 KB
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
# syntax=docker/dockerfile:1.7
# Multi-stage build: install + build native deps in stage 1, copy the
# resulting node_modules into a slim runtime image in stage 2. The
# node-gyp install hook auto-fired by npm needs python3/make/g++ to
# evaluate binding.gyp even when the prebuilt N-API binary is used.
FROM node:22-bookworm-slim AS deps
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 build-essential ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --no-audit --no-fund \
&& npm cache clean --force
FROM node:22-bookworm-slim
WORKDIR /app
# Run as root. The bind-mounted /data volume on Unraid (and most hosts) is
# owned by UID 99 ("nobody") with mode 0775, so the official image's
# unprivileged "node" user (UID 1000) cannot create life.db inside it and
# the container fails with SQLITE_CANTOPEN on boot. Root inside a single-
# purpose app container with no exposed shell is fine for this use case.
COPY --from=deps /app/node_modules ./node_modules
COPY package.json ./
COPY server.js ./
# lib/ holds the runtime modules (lib/user-model, lib/sync/plex,
# lib/sync/kavita, lib/calendar-sources, lib/graph-source, lib/dedup,
# lib/health-checker, lib/secret-box, lib/snapshot, lib/agent-tokens,
# lib/agent-endpoints, lib/drawer-dispatcher). server.js requires
# './lib/user-model' at boot, so dropping this directory in the
# runtime stage leaves the container unable to start with
# `Error: Cannot find module './lib/user-model'` (PHA-2001).
COPY lib ./lib
COPY public ./public
ENV DATA_DIR=/data PORT=3080 NODE_ENV=production
VOLUME /data
EXPOSE 3080
CMD ["node", "server.js"]