# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2.schema.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: immich
spec:
  interval: 5m
  chart:
    spec:
      chart: app-template
      version: 3.5.1
      sourceRef:
        kind: HelmRepository
        name: bjws-charts
        namespace: flux-system
  values:
    controllers:
      immich:
        containers:
          app:
            image:
              repository: ghcr.io/immich-app/immich-server
              tag: v1.122.3
            envFrom: &envFrom
              - secretRef:
                  name: immich-secret
            probes:
              liveness: &probes
                enabled: true
                custom: true
                spec:
                  httpGet:
                    path: /
                    port: &port 2283
                  initialDelaySeconds: 0
                  periodSeconds: 10
                  timeoutSeconds: 1
                  failureThreshold: 3
              readiness: *probes
              startup:
                enabled: true
                spec:
                  failureThreshold: 30
                  periodSeconds: 10
            # resources:
            #   requests:
            #     cpu: 2m
            #     memory: 1500Mi
            #   limits:
            #     memory: 3200Mi
          machine-learning:
            image:
              repository: ghcr.io/immich-app/immich-machine-learning
              tag: v1.122.3-openvino
            envFrom: *envFrom
            resources:
              limits:
                gpu.intel.com/i915: 1
#    defaultPodOptions:
#      securityContext:
#        runAsUser: 10000
#        runAsGroup: 10000
#        fsGroup: 10000
#        fsGroupChangePolicy: OnRootMismatch
    
    service:
      app:
        controller: immich
        ports:
          http:
            port: *port
          mlhttp:
            port: 3003
    
    ingress:
      app:
        annotations:
          cert-manager.io/cluster-issuer: letsencrypt-production
          traefik.ingress.kubernetes.io/router.entrypoints: websecure
        hosts:
          - host: "immich.${SECRET_NEW_DOMAIN}"
            paths:
              - path: /
                service:
                  identifier: app
                  port: http
                  
    persistence:
      mlcache:
        type: emptyDir
        accessMode: ReadWriteMany
        size: 10Gi
        advancedMounts:
          immich: # controller name
            machine-learning: # container name
            - path: /cache
      storage:
        type: hostPath
        hostPath: /mnt/MainPool/Media/Photos
        advancedMounts:
          immich:
            app:
            - path: /usr/src/app/upload