42 lines
1.8 KiB
Docker
42 lines
1.8 KiB
Docker
# ---------------------------------------------------------------------------
|
|
# Church key register
|
|
# Self-contained image: source, dependencies and static assets all baked in.
|
|
# Push it to a registry and run it anywhere without the source tree.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Stage 1 — dependencies only.
|
|
# package.json is copied on its own so `npm install` is cached and does not
|
|
# re-run every time you edit a .js file. better-sqlite3 is native, and on ARM
|
|
# hardware there may be no prebuilt binary, so a compiler must be present.
|
|
FROM node:22-bookworm-slim AS deps
|
|
WORKDIR /app
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3 make g++ ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
COPY package.json ./
|
|
RUN npm install --omit=dev --no-audit --no-fund
|
|
|
|
# Stage 2 — runtime. No compiler shipped.
|
|
FROM node:22-bookworm-slim
|
|
WORKDIR /app
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
sqlite3 ca-certificates && rm -rf /var/lib/apt/lists/* \
|
|
&& mkdir -p /data && chown node:node /data
|
|
|
|
COPY --from=deps --chown=node:node /app/node_modules ./node_modules
|
|
|
|
# Everything else. .dockerignore decides what stays out — read it before
|
|
# changing anything here, because that file is what keeps your database and
|
|
# your .env from being baked into an image you might push to a registry.
|
|
COPY --chown=node:node . .
|
|
|
|
# Files downloaded from a browser often arrive owner-only (600), and COPY
|
|
# preserves the mode. Without this the non-root user cannot read its own code.
|
|
RUN chmod -R a+rX /app
|
|
|
|
ENV NODE_ENV=production DATA_DIR=/data PORT=3000 UI_LANG=pt
|
|
EXPOSE 3000
|
|
USER node
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \
|
|
CMD node -e "fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
|
CMD ["node", "server.js"]
|