From 1c3dd305b859266292d0751edae13f4343788c53 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Mon, 13 Apr 2026 16:23:51 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20all=203=20Dockerfiles=20=E2=80=94=20Pris?= =?UTF-8?q?ma=20copy,=20standalone=20paths,=20maturin=20PATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - API: copy .prisma + @prisma into pruned node_modules, restore dist/prisma COPY - Web: fix standalone paths for monorepo (node_modules + apps/web/server.js) - AI: source cargo env in same RUN layer, wrap fallback pip install in subshell Co-Authored-By: Claude Opus 4 (1M context) --- apps/api/Dockerfile | 9 ++++----- apps/web/Dockerfile | 5 ++++- libs/ai-services/Dockerfile | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index a1b3feb..ec22392 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -36,7 +36,9 @@ RUN npx prisma generate \ # Use pnpm deploy to produce a flat, production-only node_modules # This strips devDependencies and hoists only what @goodgo/api needs. -RUN pnpm deploy --legacy --filter @goodgo/api --prod /app/pruned +RUN pnpm deploy --legacy --filter @goodgo/api --prod /app/pruned \ + && cp -r /app/node_modules/.prisma /app/pruned/node_modules/.prisma \ + && cp -r /app/node_modules/@prisma /app/pruned/node_modules/@prisma # ---- Production ---- FROM node:22-slim AS production @@ -55,15 +57,12 @@ WORKDIR /app ENV NODE_ENV=production -# Copy pruned production node_modules from pnpm deploy +# Copy pruned production node_modules from pnpm deploy (includes Prisma) COPY --from=build --chown=node:node /app/pruned/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 into node_modules -COPY --from=build --chown=node:node /app/node_modules/.prisma ./node_modules/.prisma -COPY --from=build --chown=node:node /app/node_modules/@prisma/client ./node_modules/@prisma/client # Package metadata COPY --from=build --chown=node:node /app/apps/api/package.json ./package.json # Entrypoint script diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 24401e7..adffde2 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -28,8 +28,11 @@ ENV HOSTNAME=0.0.0.0 ENV PORT=3000 # Ensure public dir exists (may be empty) then copy Next.js standalone output +# In monorepo, standalone outputs to: .next/standalone/ (root with node_modules) +# and .next/standalone/apps/web/ (server.js + .next/) RUN mkdir -p ./public -COPY --from=build --chown=node:node /app/apps/web/.next/standalone ./ +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/node_modules ./node_modules +COPY --from=build --chown=node:node /app/apps/web/.next/standalone/apps/web ./ COPY --from=build --chown=node:node /app/apps/web/.next/static ./.next/static # Copy public assets if any exist (may be empty) COPY --from=build --chown=node:node /app/apps/web/public ./public diff --git a/libs/ai-services/Dockerfile b/libs/ai-services/Dockerfile index 5dd023a..f7c432c 100644 --- a/libs/ai-services/Dockerfile +++ b/libs/ai-services/Dockerfile @@ -7,11 +7,11 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends gcc g++ dumb-init curl && \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal && \ rm -rf /var/lib/apt/lists/* -ENV PATH="/root/.cargo/bin:${PATH}" COPY pyproject.toml . -RUN pip install --no-cache-dir maturin && \ - pip install --no-cache-dir . 2>/dev/null || pip install --no-cache-dir \ +RUN . /root/.cargo/env && \ + pip install --no-cache-dir maturin && \ + (pip install --no-cache-dir . 2>/dev/null || pip install --no-cache-dir \ "fastapi==0.115.0" \ "uvicorn[standard]==0.32.0" \ "xgboost==2.1.0" \ @@ -20,7 +20,7 @@ RUN pip install --no-cache-dir maturin && \ "pydantic==2.9.0" \ "pydantic-settings==2.5.0" \ "httpx==0.27.0" \ - "slowapi==0.1.9" + "slowapi==0.1.9") COPY app/ ./app/