fix: find better-sqlite3 native binding in pnpm store

pnpm uses .pnpm symlink store, so the binding isn't at the
standard node_modules path. Use find to locate the .node file
and copy it to where Nitro expects it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Martinez
2026-04-07 14:27:02 +02:00
parent 0728211857
commit c8afee2b6c

View File

@@ -6,13 +6,15 @@ 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 mkdir -p /data && chown node:node /data
COPY --from=build /app/.output ./.output
COPY --from=build /app/node_modules/better-sqlite3/build ./.output/server/node_modules/better-sqlite3/build
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=15s \