- Updated the Dockerfile to ensure better-sqlite3 is rebuilt from source by removing prebuilds and using node-gyp. - Added verification checks to confirm the successful compilation of better_sqlite3.node and the absence of prebuilds. - Enhanced dependency management during the Docker build process.
54 lines
1.5 KiB
Docker
54 lines
1.5 KiB
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# better-sqlite3 is a native addon — compile it in a Debian (glibc) builder,
|
|
# then copy node_modules into a slim runner. Do not reuse host node_modules.
|
|
|
|
FROM node:22-bookworm-slim AS builder
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends python3 make g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
# better-sqlite3 ships linux-arm64 prebuilds that need GLIBC >= 2.38; bookworm
|
|
# has 2.36. Its gypfile skips compiling when a prebuild exists unless
|
|
# --force_build=1. Remove prebuilds, then compile against this image's glibc.
|
|
RUN npm ci \
|
|
&& npm install --no-save --no-audit --no-fund node-gyp \
|
|
&& rm -rf node_modules/better-sqlite3/prebuilds \
|
|
&& cd node_modules/better-sqlite3 \
|
|
&& npx node-gyp rebuild --release --force_build=1 \
|
|
&& cd /app \
|
|
&& test -f node_modules/better-sqlite3/build/Release/better_sqlite3.node
|
|
|
|
COPY web ./web
|
|
COPY src ./src
|
|
RUN npm run build:web \
|
|
&& npm prune --omit=dev \
|
|
&& test -f node_modules/better-sqlite3/build/Release/better_sqlite3.node \
|
|
&& test ! -d node_modules/better-sqlite3/prebuilds
|
|
|
|
FROM node:22-bookworm-slim AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV DATA_DIR=/app/data
|
|
ENV PORT=3000
|
|
ENV WATCH_CRON="0 * * * *"
|
|
ENV WATCH_TITLE_INTERVAL_HOURS="24"
|
|
|
|
COPY package.json package-lock.json ./
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/public ./public
|
|
COPY src ./src
|
|
|
|
RUN mkdir -p /app/data
|
|
|
|
EXPOSE 3000
|
|
VOLUME ["/app/data"]
|
|
|
|
CMD ["node", "src/server/index.js"]
|