From 2b343887231e57e10b12ba3e8f204d438053b755 Mon Sep 17 00:00:00 2001 From: ordinarthur <@arthurbarre.js@gmail.com> Date: Sat, 9 May 2026 15:27:45 +0200 Subject: [PATCH] fix(landing): copie le workspace + node_modules pruned en runner stage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le bundle Astro standalone (dist/server/entry.mjs) référence quand même certaines deps externes (react, react-dom, lucide-react, sharp). En ne copiant que dist/ vers le runner, le pod crashait au boot — Node ne trouvait pas les modules → startupProbe failed → rollout K3s timeout. Stratégie miroir de Dockerfile.api : on prune les devDeps après build, puis on copie tout /repo dans /app. Les workspace symlinks (apps/landing ↔ packages/ui ↔ packages/shared) restent fonctionnels, les hoisted deps (react, etc.) sont résolus depuis /app/node_modules. CMD ajusté à `node ./dist/server/entry.mjs` (relative depuis le WORKDIR /app/apps/landing) pour cohérence. Co-Authored-By: Claude Opus 4.7 --- Dockerfile.landing | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Dockerfile.landing b/Dockerfile.landing index 6e50c17..c031ec2 100644 --- a/Dockerfile.landing +++ b/Dockerfile.landing @@ -5,8 +5,10 @@ # ============================================================================= # # Astro adapter: @astrojs/node en mode "standalone" → bundle un mini-server -# Node dans dist/server/entry.mjs. Pas de nginx en frontal nécessaire au -# niveau du pod : Traefik (cluster) gère le TLS et le routing par hostname. +# Node dans dist/server/entry.mjs. Le bundle référence quand même certaines +# deps externes (react, react-dom, lucide-react, sharp...), donc on copie +# le workspace entier dans le runner stage avec les node_modules pruned +# (--prod). Stratégie miroir de Dockerfile.api. # ============================================================================= ARG NODE_VERSION=22.13.1 @@ -42,6 +44,12 @@ COPY packages/ui ./packages/ui COPY apps/landing ./apps/landing RUN cd apps/landing && pnpm exec astro build +# Prune devDeps. Les workspace symlinks restent intacts. Le stage runner +# copie ensuite le repo entier — pnpm a besoin de la structure complète +# pour résoudre les imports (workspace + hoist). +RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ + pnpm install --prod --frozen-lockfile=false --filter @rubis/landing... + # ----------------------------------------------------------------------------- # runner — runtime minimal, user non-root # ----------------------------------------------------------------------------- @@ -55,17 +63,19 @@ ENV NODE_ENV=production \ WORKDIR /app -# Astro standalone bundle suffit (server + client static + node_modules -# nécessaires à l'entry sont déjà inclus dans dist/). -COPY --from=build --chown=astro:nodejs /repo/apps/landing/dist /app/dist +# Copie le repo entier (avec node_modules prod pruned + workspace symlinks +# + dist/ Astro). Node résout les imports via /app/apps/landing/node_modules +# puis remonte dans /app/node_modules (hoisted). +COPY --from=build --chown=astro:nodejs /repo /app USER astro +WORKDIR /app/apps/landing EXPOSE 4321 -# Healthcheck simple : / répond 200 (page d'accueil prerenderée). +# Healthcheck : / répond 200 (prerendered, pas besoin de l'API). HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ CMD wget -qO- http://127.0.0.1:4321/ >/dev/null 2>&1 || exit 1 ENTRYPOINT ["/sbin/tini", "--"] -CMD ["node", "/app/dist/server/entry.mjs"] +CMD ["node", "./dist/server/entry.mjs"]