From 6c8ad5c4f9d6382db41495040bb837b5953974d1 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Date: Tue, 7 Apr 2026 14:37:39 +0200 Subject: [PATCH] fix: use single-stage Docker build for native bindings Multi-stage builds break better-sqlite3 because the native .node binding and its bindings/file-uri-to-path deps need to be in node_modules at runtime. Single stage keeps everything in place. Co-Authored-By: Claude Opus 4.6 (1M context) --- Dockerfile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64af88c..f41bdc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24-alpine AS build +FROM node:24-alpine RUN apk add --no-cache python3 make g++ WORKDIR /app RUN corepack enable pnpm @@ -6,16 +6,10 @@ COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile COPY . . RUN pnpm run build -# Copy better-sqlite3 native binding to where Nitro expects it -RUN find /app/node_modules/.pnpm -name "better_sqlite3.node" -path "*/Release/*" | head -1 | \ - xargs -I{} sh -c 'mkdir -p .output/server/node_modules/better-sqlite3/build/Release && cp "{}" .output/server/node_modules/better-sqlite3/build/Release/' - -FROM node:24-alpine AS run -ENV NODE_ENV=production -WORKDIR /app +RUN apk del python3 make g++ && rm -rf /root/.cache /tmp/* RUN mkdir -p /data && chown node:node /data -COPY --from=build /app/.output ./.output USER node +ENV NODE_ENV=production EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=15s \ CMD wget -q --spider http://localhost:3000/api/health || exit 1