fix(deploy): install dev deps in builder so tsc is available, keep production deps in final image

This commit is contained in:
2025-08-25 09:45:52 +08:00
parent cbd6cd41de
commit 24fe649a1c

View File

@@ -1,8 +1,8 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY backend/package*.json backend/
# Use npm ci if a lockfile exists in backend, otherwise fall back to npm install
RUN sh -c 'if [ -f backend/package-lock.json ] || [ -f backend/npm-shrinkwrap.json ]; then npm ci --prefix backend --production; else npm install --prefix backend --production; fi'
# Install all dependencies (including dev) in builder so tools like tsc are available for build
RUN sh -c 'if [ -f backend/package-lock.json ] || [ -f backend/npm-shrinkwrap.json ]; then npm ci --prefix backend; else npm install --prefix backend; fi'
COPY backend/ backend/
RUN npm run build --prefix backend