From b84dfd5cadb486152911483460dd17531888e85e Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Mon, 13 Apr 2026 15:31:08 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20Docker=20build=20errors=20=E2=80=94=20Pr?= =?UTF-8?q?isma=20generate=20order,=20.dockerignore=20multi-service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: move prisma generate BEFORE nest build (fixes TS2305 PropertyType) - .dockerignore: remove apps/web + libs/ai-services exclusions (needed by Kaniko) - CI: add pnpm db:generate step before lint/typecheck/build Co-Authored-By: Claude Opus 4 (1M context) --- .dockerignore | 51 +++++++++++++++++++++++----------------- .github/workflows/ci.yml | 3 +++ apps/api/Dockerfile | 10 ++++---- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index ded8f55..e78d19e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,19 @@ +# ============================================================================= +# .dockerignore — shared across ALL Dockerfiles (api, web, ai-services) +# All 3 Dockerfiles build from repo root context, so do NOT exclude +# apps/web or libs/ai-services here. +# ============================================================================= + +# Build outputs & caches (rebuilt inside Docker) node_modules .next dist *.tsbuildinfo +.turbo +.cache +.nx +.eslintcache +coverage # Version control .git @@ -9,15 +21,21 @@ dist .husky .gitignore -# Documentation and tests +# Documentation, tests, monitoring (not needed in any build) docs e2e +load-tests +monitoring playwright-report -*.md -!README.md +playwright.config.ts +CHANGELOG.md +CONTRIBUTING.md +SEED_GENERATION_SCRIPT.ts -# Environment and secrets -.env* +# Environment and secrets (NEVER ship into images) +.env +.env.ci +.env.test !.env.example # IDE and editor @@ -26,35 +44,24 @@ playwright-report *.swp *.swo -# Build caches -.eslintcache -coverage -.turbo -.cache -.nx - # OS files .DS_Store Thumbs.db -# Docker files (avoid recursive context) +# Docker / infra files (avoid recursive context) docker-compose*.yml Dockerfile* -monitoring +infra -# Dev tools -scripts/backup +# Dev tools & scripts (not needed at build time) +scripts *.log -# Python / AI services (not needed for API build) -libs/ai-services +# Python caches (rebuilt inside AI container) __pycache__ *.pyc .venv -# Frontend (not needed for API build, has its own Dockerfile) -apps/web - -# Agent configs (Paperclip / Claude) +# Agent / Claude configs .claude agents diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4786f5..89ec040 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,9 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Generate Prisma client + run: pnpm db:generate + - name: Lint run: pnpm lint diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index a70ef7d..c13bc3e 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -19,8 +19,8 @@ COPY prisma/ prisma/ RUN pnpm install --frozen-lockfile --filter @goodgo/api... # ---- Build ---- -# Compile TypeScript for mcp-servers lib (workspace dep), then the NestJS API, -# then generate the Prisma client. +# Generate Prisma client first (TS types needed at compile time), +# then compile mcp-servers lib (workspace dep), then the NestJS API. FROM base AS build COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules @@ -30,9 +30,9 @@ COPY prisma/ prisma/ COPY libs/mcp-servers/ libs/mcp-servers/ COPY apps/api/ apps/api/ -RUN pnpm --filter @goodgo/mcp-servers build 2>/dev/null || true \ - && cd apps/api && npx nest build \ - && cd /app && npx prisma generate +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 # This strips devDependencies and hoists only what @goodgo/api needs.