# ─── Media uploads volume (Payload writes to /app/media) ─────────────────────
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rebours-media-data
  namespace: rebours
spec:
  accessModes: [ReadWriteOnce]
  storageClassName: local-path
  resources:
    requests:
      storage: 5Gi
---
# ─── Next.js + Payload CMS (single process) ───────────────────────────────────
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rebours-web
  namespace: rebours
  labels:
    app: rebours-web
spec:
  replicas: 1
  strategy:
    # Single-replica app writing to a RWO volume — recreate instead of rolling
    type: Recreate
  selector:
    matchLabels:
      app: rebours-web
  template:
    metadata:
      labels:
        app: rebours-web
    spec:
      imagePullSecrets:
        - name: gitea-registry-secret
      containers:
        - name: rebours-web
          image: git.arthurbarre.fr/ordinarthur/rebours-web:latest
          ports:
            - containerPort: 3000
          envFrom:
            - configMapRef:
                name: rebours-config
            - secretRef:
                name: rebours-secrets
          volumeMounts:
            - name: media
              mountPath: /app/media
          resources:
            requests:
              memory: "384Mi"
              cpu: "200m"
            limits:
              memory: "1Gi"
              cpu: "1000m"
          readinessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 15
            periodSeconds: 10
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 30
            periodSeconds: 30
      volumes:
        - name: media
          persistentVolumeClaim:
            claimName: rebours-media-data
