apiVersion: apps/v1
kind: Deployment
metadata:
  name: ghostfolio
  namespace: ai
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ghostfolio
  template:
    metadata:
      labels:
        app: ghostfolio
    spec:
      containers:
        - name: ghostfolio
          image: ghostfolio/ghostfolio:latest
          ports:
            - containerPort: 3333
          env:
            # PostgreSQL sur storage-01 (hors cluster) — chaîne complète dans le secret
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: ghostfolio-secret
                  key: database-url
            # Redis (in-cluster)
            - name: REDIS_HOST
              value: "ghostfolio-redis"
            - name: REDIS_PORT
              value: "6379"
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ghostfolio-secret
                  key: redis-password
            # Secrets applicatifs Ghostfolio
            - name: ACCESS_TOKEN_SALT
              valueFrom:
                secretKeyRef:
                  name: ghostfolio-secret
                  key: access-token-salt
            - name: JWT_SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: ghostfolio-secret
                  key: jwt-secret-key
            - name: PORT
              value: "3333"
            - name: TZ
              value: "Europe/Paris"
          resources:
            requests:
              cpu: 200m
              memory: 512Mi
            limits:
              cpu: 1000m
              memory: 1Gi
          readinessProbe:
            httpGet:
              path: /api/v1/health
              port: 3333
            initialDelaySeconds: 30
            periodSeconds: 15
          livenessProbe:
            httpGet:
              path: /api/v1/health
              port: 3333
            initialDelaySeconds: 60
            periodSeconds: 30
