rubis/k3s/app/web.yml
ordinarthur dd93249362
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 1m16s
Build & Deploy API / build-and-deploy (push) Successful in 1m32s
refactor(deploy): split monolithique en 2 services (rubis-web nginx + rubis-api Node)
Avant : une seule image (Dockerfile.app) qui bundle AdonisJS + SPA static.
Après : deux images, deux deployments, deux workflows CI avec path filters
indépendants.

Architecture
- rubis-web (NodePort 30110, exposé via Traefik)
  · nginx-alpine + SPA Vite dist + nginx.conf
  · sert /assets/* (cache 1y immutable), / (try_files index.html SPA fallback)
  · reverse-proxy /api/* → rubis-api.rubis.svc.cluster.local:3333
- rubis-api (ClusterIP, accessible uniquement depuis le cluster)
  · AdonisJS V7 + workers BullMQ dans le même process
  · init-container migrate (idempotent, depuis build/)
  · /api/v1/health pour les probes K3s + healthcheck Docker
- rubis-redis (ClusterIP, inchangé)

Bénéfices
- Build/deploy indépendants : changement front ne reconstruit pas l'API,
  changement API ne reconstruit pas le SPA
- nginx en frontal donne du gzip + cache long sur les assets fingerprintés
- API n'expose plus de surface publique (defense in depth)
- Routes plus simples : on retire le wildcard SPA fallback dans
  start/routes.ts (nginx s'en charge), on retire @adonisjs/static aurait
  été cohérent mais on le garde pour minimiser les diffs

Files
- Dockerfile.api (replaces Dockerfile.app, Node-only)
- Dockerfile.web (new, nginx)
- apps/web/nginx.conf (new)
- k3s/app/api.yml (replaces deployment.yml + service.yml, ClusterIP)
- k3s/app/web.yml (new, NodePort 30110)
- .gitea/workflows/deploy-{api,web}.yml (replaces deploy-app.yml)
- /api/v1/health route ajoutée

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 02:58:25 +02:00

67 lines
1.6 KiB
YAML

# Rubis Web — nginx + SPA static + reverse proxy /api/* → rubis-api ClusterIP.
# Seul service exposé via Traefik (NodePort 30110 → app.rubis.arthurbarre.fr).
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rubis-web
namespace: rubis
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: rubis-web
template:
metadata:
labels:
app: rubis-web
spec:
imagePullSecrets:
- name: gitea-registry
containers:
- name: web
image: git.arthurbarre.fr/ordinarthur/rubis-web:latest
imagePullPolicy: Always
ports:
- containerPort: 80
name: http
resources:
requests:
cpu: 50m
memory: 32Mi
limits:
cpu: 200m
memory: 128Mi
livenessProbe:
httpGet: { path: /index.html, port: http }
periodSeconds: 30
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet: { path: /index.html, port: http }
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
---
# NodePort 30110 — exposé par Traefik sur la gateway VM (cf.
# ansible/roles/traefik/templates/rubis-app.yml.j2).
apiVersion: v1
kind: Service
metadata:
name: rubis-web
namespace: rubis
spec:
type: NodePort
selector:
app: rubis-web
ports:
- port: 80
targetPort: http
nodePort: 30110
name: http