From 4870ac92148b74f6f958fdcde99d26126b0c4ebf Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Tue, 14 Apr 2026 01:12:31 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20API=20Dockerfile=20=E2=80=94=20copy=20fu?= =?UTF-8?q?ll=20node=5Fmodules=20instead=20of=20pnpm=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pnpm deploy --legacy --prod doesn't resolve all transitive deps correctly in monorepo. Copy full node_modules from build stage instead. Also add openssl to production image (required by Prisma at runtime). Co-Authored-By: Claude Opus 4 (1M context) --- apps/api/Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 448e89e..86cf387 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -34,10 +34,6 @@ RUN npx prisma generate \ && (pnpm --filter @goodgo/mcp-servers build 2>/dev/null || true) \ && cd apps/api && npx nest build -# Use pnpm deploy to produce a flat, production-only node_modules -# Copy generated Prisma client from build stage (pnpm deploy doesn't carry it) -RUN pnpm deploy --legacy --filter @goodgo/api --prod /app/pruned - # ---- Production ---- FROM node:22-slim AS production @@ -48,22 +44,19 @@ LABEL org.opencontainers.image.title="goodgo-api" \ # dumb-init for proper PID 1 signal handling RUN apt-get update \ - && apt-get install -y --no-install-recommends dumb-init \ + && apt-get install -y --no-install-recommends dumb-init openssl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app ENV NODE_ENV=production -# Copy pruned production node_modules -COPY --from=build --chown=node:node /app/pruned/node_modules ./node_modules +# Copy full node_modules from build stage (pnpm deploy --prod is unreliable in monorepo) +COPY --from=build --chown=node:node /app/node_modules ./node_modules # Copy compiled application COPY --from=build --chown=node:node /app/apps/api/dist ./dist # Prisma schema + migrations (needed for runtime client & migrate deploy) COPY --from=build --chown=node:node /app/prisma ./prisma -# Copy generated Prisma client from build stage (not from pruned) -COPY --from=build --chown=node:node /app/node_modules/.pnpm/@prisma+client@*/node_modules/@prisma/client ./node_modules/@prisma/client -COPY --from=build --chown=node:node /app/node_modules/.pnpm/@prisma+client@*/node_modules/.prisma ./node_modules/.prisma # Package metadata COPY --from=build --chown=node:node /app/apps/api/package.json ./package.json # Entrypoint script