# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2beta2.schema.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: huginn
  namespace: default
spec:
  interval: 5m
  chart:
    spec:
      chart: app-template
      version: 3.1.0
      sourceRef:
        kind: HelmRepository
        name: bjws-charts
        namespace: flux-system

  values:
    controllers:
      main:
        pod:
          securityContext:
            runAsNonRoot: true
#            runAsUser: 10000
#            runAsGroup: 10000
#            fsGroup: 10000
#            fsGroupChangePolicy: OnRootMismatch

        containers:
          main:
            image:
              repository: ghcr.io/huginn/huginn
              tag: 0533a3768537f7a6a157227bfd9a9caefada768f

            command:
            - /scripts/init
            - bin/threaded.rb

            env:
              DATABASE_ADAPTER: postgresql
              DATABASE_HOST: postgres16-rw.database.svc
              DATABASE_PORT: 5432

              DATABASE_NAME: huginn
              DATABASE_RECONNECT: true
              # Specified in huginn-env
              # DATABASE_USERNAME:
              # DATABASE_PASSWORD:

              #TIMEZONE: ${SERVER_TIMEZONE}
              USE_GRAPHVIZ_DOT: dot
              USE_EVERNOTE_SANDBOX: false # set to production

            envFrom:
              - secretRef:
                  name: huginn-env

    service:
      app:
        controller: main

        ports:
          http:
            port: 3000

    ingress:
      main:
        annotations:
          cert-manager.io/cluster-issuer: letsencrypt-production
          traefik.ingress.kubernetes.io/router.entrypoints: websecure

        hosts:
        - host: "huginn.${SECRET_NEW_DOMAIN}"
          paths:
          - path: /
            service:
              identifier: app
              port: http