- Added steps to remove prebuilds of better-sqlite3 to ensure compatibility with the image's glibc. - Included verification checks for the existence of the compiled better_sqlite3.node file after rebuild and prune operations. - Improved overall dependency management in the Docker build process.
50 lines
1.4 KiB
Docker
50 lines
1.4 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 ./
|
|
# Compile against this image's glibc, then remove prebuilds — better-sqlite3
|
|
# always prefers prebuilds/ over build/Release, and published linux-arm64
|
|
# prebuilds can require a newer GLIBC than bookworm provides.
|
|
RUN npm ci \
|
|
&& npm rebuild better-sqlite3 --build-from-source \
|
|
&& rm -rf node_modules/better-sqlite3/prebuilds \
|
|
&& 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
|
|
|
|
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"]
|