Files
temetro/backend/Dockerfile
T
Khalid Abdi af956a2779 backend: skip native build scripts in Docker build stage
The build stage ran `npm ci`, which tried to compile better-sqlite3 — a
dev-only transitive dependency of @better-auth/cli — and failed in Alpine for
lack of Python/node-gyp. The build step is just `tsc` (no native binaries
needed) and better-sqlite3 is never used at runtime (the prod stage omits dev
deps), so install dev deps with --ignore-scripts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 18:56:14 +03:00

24 lines
869 B
Docker

# --- build stage: compile TypeScript -> dist ------------------------------
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
# --ignore-scripts skips native postinstall builds (e.g. better-sqlite3, a
# dev-only dependency of @better-auth/cli that needs Python/node-gyp). The build
# step is just `tsc`, which needs no compiled binaries, and better-sqlite3 is
# never used at runtime (the prod stage omits dev deps).
RUN npm ci --ignore-scripts
COPY . .
RUN npm run build
# --- runtime stage: prod deps only -----------------------------------------
FROM node:22-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --omit=dev
COPY --from=build /app/dist ./dist
COPY --from=build /app/drizzle ./drizzle
EXPOSE 4000
# Apply migrations, then start the API.
CMD ["sh", "-c", "node dist/migrate.js && node dist/index.js"]