fix(landing): copie le workspace + node_modules pruned en runner stage
All checks were successful
Build & Deploy Landing / build-and-deploy (push) Successful in 48s

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 <noreply@anthropic.com>
This commit is contained in:
ordinarthur 2026-05-09 15:27:45 +02:00
parent 566febca48
commit 2b34388723

View File

@ -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"]