fix(docker): Copy node_modules from builder instead of reinstalling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
pnpm stores the Prisma client in the content-addressable store at node_modules/.pnpm/.../.prisma, not at apps/api/node_modules/.prisma. The production stage was trying to copy from the wrong location. Additionally, running `pnpm install --prod` in production failed because: 1. The husky prepare script runs but husky is a devDependency 2. The Prisma client postinstall can't run without the prisma CLI Fixed by copying the full node_modules from the builder stage, which already has all dependencies properly installed and the Prisma client generated in the correct pnpm store location. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,9 +48,6 @@ RUN pnpm turbo build --filter=@mosaic/api
|
||||
# ======================
|
||||
FROM node:20-alpine AS production
|
||||
|
||||
# Install pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@10.19.0 --activate
|
||||
|
||||
# Install dumb-init for proper signal handling
|
||||
RUN apk add --no-cache dumb-init
|
||||
|
||||
@@ -59,24 +56,17 @@ RUN addgroup -g 1001 -S nodejs && adduser -S nestjs -u 1001
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY --chown=nestjs:nodejs pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
||||
COPY --chown=nestjs:nodejs turbo.json ./
|
||||
# Copy node_modules from builder (includes generated Prisma client in pnpm store)
|
||||
# pnpm stores the Prisma client in node_modules/.pnpm/.../.prisma, so we need the full tree
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
|
||||
|
||||
# Copy package.json files for workspace resolution
|
||||
COPY --chown=nestjs:nodejs packages/shared/package.json ./packages/shared/
|
||||
COPY --chown=nestjs:nodejs packages/ui/package.json ./packages/ui/
|
||||
COPY --chown=nestjs:nodejs packages/config/package.json ./packages/config/
|
||||
COPY --chown=nestjs:nodejs apps/api/package.json ./apps/api/
|
||||
|
||||
# Install production dependencies only
|
||||
RUN pnpm install --prod --frozen-lockfile
|
||||
|
||||
# Copy built application and dependencies
|
||||
# Copy built packages (includes dist/ directories)
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/packages ./packages
|
||||
|
||||
# Copy built API application
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/apps/api/dist ./apps/api/dist
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/apps/api/prisma ./apps/api/prisma
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/apps/api/node_modules/.prisma ./apps/api/node_modules/.prisma
|
||||
COPY --from=builder --chown=nestjs:nodejs /app/apps/api/package.json ./apps/api/
|
||||
|
||||
# Set working directory to API app
|
||||
WORKDIR /app/apps/api
|
||||
|
||||
Reference in New Issue
Block a user