From 040e787ee5e3e1c2633f74ec8999602bc4fd2d93 Mon Sep 17 00:00:00 2001 From: ordinarthur <@arthurbarre.js@gmail.com> Date: Thu, 7 May 2026 12:41:15 +0200 Subject: [PATCH] chore(seed): rendre seed:demo utilisable en prod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile.api : copie `assets/test-invoices/` dans l'image (les 27 PDFs servent au seed démo, ~80KB, négligeable). - factories.ts : ajout d'un 3e candidat de chemin pour couvrir le contexte prod où la commande tourne depuis `/app/apps/api/build`. Permet de peupler une org démo en prod via : kubectl -n rubis exec -it deploy/rubis-api -- \\ sh -c 'cd /app/apps/api/build && node ace.js seed:demo \\ --email --reset --org-name=""' Co-Authored-By: Claude Opus 4.7 --- Dockerfile.api | 3 +++ apps/api/database/factories.ts | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile.api b/Dockerfile.api index 21a2667..73911ec 100644 --- a/Dockerfile.api +++ b/Dockerfile.api @@ -43,6 +43,9 @@ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ FROM deps AS build COPY packages/shared ./packages/shared COPY apps/api ./apps/api +# Inclus les PDFs de démo pour le command `seed:demo` (lancé manuellement +# en prod via `kubectl exec`). 27 fichiers, ~80KB total — négligeable. +COPY assets ./assets RUN cd apps/api && pnpm exec tsx ace.js build --ignore-ts-errors # Prune devDeps (les workspace symlinks restent). diff --git a/apps/api/database/factories.ts b/apps/api/database/factories.ts index 90ae5aa..7a609fd 100644 --- a/apps/api/database/factories.ts +++ b/apps/api/database/factories.ts @@ -414,12 +414,15 @@ async function seedSyntheticActionable( // --------------------------------------------------------------------------- /** - * Localise le dossier `assets/test-invoices` à la racine du repo. Le command - * tourne depuis `apps/api/`, donc on remonte de 2 niveaux. + * Localise le dossier `assets/test-invoices`. La résolution couvre 3 contextes : + * - dev local : cwd = `apps/api/` → `../../assets/test-invoices` + * - prod (init) : cwd = `/app/apps/api` → `../../assets/test-invoices` + * - prod (build) : cwd = `/app/apps/api/build` → `../../../assets/test-invoices` */ function resolveTestInvoicesDir(): string | null { const candidates = [ join(process.cwd(), '..', '..', 'assets', 'test-invoices'), + join(process.cwd(), '..', '..', '..', 'assets', 'test-invoices'), join(process.cwd(), 'assets', 'test-invoices'), ] for (const c of candidates) {