From 2b92492c325fc5e1f1a9619c6edb8e9de876fb92 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 6 May 2026 06:47:31 +0000 Subject: [PATCH] fix(docker): bundle prebuilt better-sqlite3 binding via pnpm deploy The runtime stage previously ran `npm install --omit=dev --ignore-scripts`, which skips better-sqlite3's install script and leaves the native binary unbuilt. Anything that loads better-sqlite3 inside the container then crashes with "Could not locate the bindings file". Use `pnpm deploy --prod --legacy` in the build stage to assemble a self-contained folder that already includes the compiled .node binary, and copy that into the runtime stage. No second install is needed. Closes #78 --- packages/context/Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/context/Dockerfile b/packages/context/Dockerfile index 9ce9daa..008acab 100644 --- a/packages/context/Dockerfile +++ b/packages/context/Dockerfile @@ -4,9 +4,13 @@ WORKDIR /app COPY . . +# pnpm deploy assembles a self-contained folder with prod deps and the +# already-built better-sqlite3 native binding, avoiding a second install +# (and the --ignore-scripts trap that left the .node file missing). RUN corepack enable \ && pnpm install --frozen-lockfile \ - && pnpm --filter @neuledge/context build + && pnpm --filter @neuledge/context build \ + && pnpm --filter @neuledge/context deploy --prod --legacy /deploy FROM node:22-bookworm-slim AS runtime @@ -17,10 +21,7 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates \ && rm -rf /var/lib/apt/lists/* -COPY --from=build /app/packages/context/dist ./dist -COPY --from=build /app/packages/context/package.json ./package.json - -RUN npm install --omit=dev --ignore-scripts +COPY --from=build /deploy ./ EXPOSE 8080