rubis/Dockerfile.web
ordinarthur e5530930b3
Some checks failed
Build & Deploy API / build-and-deploy (push) Failing after 17s
Build & Deploy Web / build-and-deploy (push) Successful in 1m15s
Build & Deploy Landing / build-and-deploy (push) Failing after 3m43s
feat: refactor frontend en stack React unifiée (Astro + packages/ui)
Trois surfaces partagent désormais le même design system, Tailwind v4
et React 19 — au lieu d'avoir landing en HTML vanilla, app en React, et
blog en Adonis SSR :

* packages/ui — design system partagé (tokens Tailwind v4 + composants
  TSX) extrait depuis apps/web : Brand, Gem, Button, Card, Chip, Eyebrow,
  EmptyState. apps/web migre 41 imports vers @rubis/ui.

* apps/landing — nouvelle app Astro 6 SSR (rubis.pro), remplace l'ancienne
  landing nginx vanilla. Embarque :
  - Landing complète portée en sections React (Hero, Stats, Promise,
    HowItWorks, Gamification, Legal, Pricing, FAQ, FinalCTA, Footnotes)
  - Pages légales (mentions, confidentialité, CGV) via LegalLayout.astro
  - Blog SSR (/blog, /blog/:slug) qui consomme /api/v1/posts
  - sitemap.xml, blog/rss.xml, robots.txt en endpoints Astro
  - SEO complet (canonical, hreflang, OG, Twitter Card, JSON-LD
    Article/BreadcrumbList/Blog/SoftwareApplication)

* apps/api — BlogController réduit à 2 endpoints JSON (GET /api/v1/posts
  + GET /api/v1/posts/:slug). Suppression des templates SSR Adonis
  (apps/api/app/blog/), de l'alias #blog/*, des deps react-dom et
  @types/react-dom. PostTransformer + PostSummaryTransformer ajoutés.
  Le service blog_renderer + le seeder + les 3 articles fondateurs
  restent intacts (réutilisés par futurs admin + cron IA).

* Infra :
  - Dockerfile.landing (multi-stage Node 22 + tini, Astro standalone)
  - k3s/app/landing.yml (Deployment + Service rubis-landing:4321 +
    ConfigMap avec API_URL=http://rubis-api.rubis.svc.cluster.local:3333)
  - .gitea/workflows/deploy.yml mis à jour pour build rubis-landing
  - .gitea/workflows/deploy-web.yml + Dockerfile.web : prennent en
    compte packages/ui/ comme dépendance
  - Suppression du Dockerfile nginx legacy + k3s/{deployment,service}.yml
  - Suppression de landing/ (assets favicons migrés vers
    apps/landing/public/)

* Docs : architecture.md (vue d'ensemble + §4bis apps/landing complet,
  §3 endpoints JSON blog, layout monorepo), CLAUDE.md (stack technique,
  documents associés, déploiement).

Note infra : l'ancien Deployment "rubis" (nginx) et son Service ne sont
PAS supprimés par la CI — à nettoyer manuellement après validation que
Traefik a été repointé sur rubis-landing:4321 dans le repo proxmox.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 15:09:13 +02:00

98 lines
3.8 KiB
Docker

# syntax=docker/dockerfile:1.7
# =============================================================================
# Rubis — image web (SPA React/Vite servi par nginx)
# Sert app.rubis.pro (front + reverse proxy /api/* → rubis-api).
# =============================================================================
ARG NODE_VERSION=22.13.1
ARG PNPM_VERSION=10.0.0
ARG NGINX_VERSION=1.27-alpine
# =============================================================================
# Build-time env vars exposées au bundle Vite (`import.meta.env.VITE_*`).
# Vite remplace ces literals à la compile, donc il faut les fournir AVANT
# `vite build`. Valeurs par défaut = prod ; surcharger via --build-arg pour
# preview/staging.
# =============================================================================
ARG VITE_API_URL=https://app.rubis.pro
ARG VITE_PUBLIC_LANDING_URL=https://rubis.pro
ARG VITE_USE_MOCKS=false
# Sentry — DSN baked dans le bundle pour init côté SPA (cf. lib/sentry.ts).
# VITE_APP_VERSION = sha git pour identifier la release dans Sentry.
ARG VITE_SENTRY_DSN_WEB=
ARG VITE_APP_VERSION=
# Sentry CI uniquement — utilisé par @sentry/vite-plugin pour upload des
# sourcemaps (cf. vite.config.ts). Ne fuit pas en runtime (consommé au build).
ARG SENTRY_AUTH_TOKEN=
ARG SENTRY_ORG=rubis
# -----------------------------------------------------------------------------
# build — Vite produit dist/
# -----------------------------------------------------------------------------
FROM node:${NODE_VERSION}-alpine AS build
ARG PNPM_VERSION
RUN apk add --no-cache libc6-compat && \
corepack enable && \
corepack prepare pnpm@${PNPM_VERSION} --activate
WORKDIR /repo
# Manifests pour cache Docker
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json tsconfig.base.json ./
COPY apps/web/package.json ./apps/web/
COPY packages/shared/package.json ./packages/shared/
COPY packages/ui/package.json ./packages/ui/
# Install : on prend tout le workspace pour que les workspace deps résolvent.
# Le filter --include-deps évite de gaspiller en installant les deps de l'API.
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY packages/shared ./packages/shared
COPY packages/ui ./packages/ui
COPY apps/web ./apps/web
# Re-déclare les ARG dans le stage où on les utilise (Docker scope).
ARG VITE_API_URL
ARG VITE_PUBLIC_LANDING_URL
ARG VITE_USE_MOCKS
ARG VITE_SENTRY_DSN_WEB
ARG VITE_APP_VERSION
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_ORG
# vite build direct (le `tsc -b` du script build plante sans cache .tsbuildinfo
# à cause de @tanstack/router-core ; le typecheck strict est en CI séparée).
# Les VITE_* env vars sont lues par Vite à la compile via process.env.
# SENTRY_AUTH_TOKEN active sentryVitePlugin (upload sourcemaps).
RUN VITE_API_URL=$VITE_API_URL \
VITE_PUBLIC_LANDING_URL=$VITE_PUBLIC_LANDING_URL \
VITE_USE_MOCKS=$VITE_USE_MOCKS \
VITE_SENTRY_DSN_WEB=$VITE_SENTRY_DSN_WEB \
VITE_APP_VERSION=$VITE_APP_VERSION \
APP_VERSION=$VITE_APP_VERSION \
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN \
SENTRY_ORG=$SENTRY_ORG \
pnpm --filter @rubis/web exec vite build
# -----------------------------------------------------------------------------
# runner — nginx-alpine + dist + config
# -----------------------------------------------------------------------------
FROM nginx:${NGINX_VERSION} AS runner
# Pas besoin de /etc/nginx/conf.d/default.conf legacy
RUN rm /etc/nginx/conf.d/default.conf
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /repo/apps/web/dist /var/www
EXPOSE 80
# Healthcheck : nginx répond 200 sur /index.html
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1/index.html >/dev/null 2>&1 || exit 1
# Démarre nginx en foreground (pas de tini nécessaire pour nginx).
CMD ["nginx", "-g", "daemon off;"]