# Build stage: compile app and native deps (better-sqlite3) for target platform. FROM node:20-bookworm-slim AS builder RUN corepack enable && corepack prepare pnpm@latest --activate WORKDIR /app COPY package.json pnpm-lock.yaml* ./ RUN pnpm install COPY . . RUN pnpm run build RUN pnpm prune --prod # Runtime: copy built artifacts and node_modules (with compiled better_sqlite3.node). FROM node:20-bookworm-slim WORKDIR /app ENV NODE_ENV=production COPY package.json ./ COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/dist ./dist EXPOSE 8080 CMD ["node", "dist/index.js"]