image:
  repository: tccr.io/truecharts/ferdi-server
  tag: v1.3.2@sha256:9cd5863593eb1f8aa6ddf695d4984f6691fff7d453e2f608a30d67bda4c58c27
  pullPolicy: IfNotPresent

securityContext:
  readOnlyRootFilesystem: false
  runAsNonRoot: false

podSecurityContext:
  runAsUser: 0
  runAsGroup: 0

env:
  NODE_ENV: "production"
  DATA_DIR: "/app/data"
  DB_CONNECTION: "pg"
  DB_PORT: "5432"
  DB_SSL: false
  DB_USER: "{{ .Values.postgresql.postgresqlUsername }}"
  DB_DATABASE: "{{ .Values.postgresql.postgresqlDatabase }}"
  # User Defined
  APP_URL: "http://localhost:3333"
  IS_CREATION_ENABLED: true
  IS_DASHBOARD_ENABLED: true
  IS_REGISTRATION_ENABLED: true
  CONNECT_WITH_FRANZ: true
  # MAIL_CONNECTION: "smtp"
  # SMTP_HOST: "localhost"
  # SMTP_PORT: 587
  # MAIL_SSL: true
  # MAIL_USERNAME: "username@example.com"
  # MAIL_PASSWORD: "password"
  # MAIL_SENDER: "noreply@example.com"
  # SPARKPOST_API_KEY: ""
  # MAILGUN_DOMAIN: ""
  # MAILGUN_API_REGION: ""
  # MAILGUN_API_KEY: ""
  DB_HOST:
    secretKeyRef:
      name: dbcreds
      key: plainhost
  DB_PASSWORD:
    secretKeyRef:
      name: dbcreds
      key: postgresql-password

probes:
  liveness:
    path: "/health"

  readiness:
    path: "/health"

  startup:
    path: "/health"

service:
  main:
    ports:
      main:
        port: 10206
        targetPort: 3333

persistence:
  data:
    enabled: true
    mountPath: "/app/data"
  recipes:
    enabled: true
    mountPath: "/app/recipes"

postgresql:
  enabled: true
  existingSecret: "dbcreds"
  postgresqlUsername: ferdi-server
  postgresqlDatabase: ferdi-server

installContainers:
  1-create-key-file:
    image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
    volumeMounts:
      - name: data
        mountPath: "/app/data"
    env:
      - name: APP_KEY
        valueFrom:
          secretKeyRef:
            name: ferdi-server-secrets
            key: APP_KEY
    command: ["sh", "-c"]
    args:
      - >
        keyfile="/app/data/FERDI_APP_KEY.txt";
        if [ ! -f ${keyfile} ];
        then
          echo "No APP_KEY File...";
          echo "Creating APP_KEY file...";
          echo "${APP_KEY}" > ${keyfile};
          if [ -f ${keyfile} ];
          then
            echo "Success!";
          else
            echo "Failed.";
          fi;
        else
          echo "APP_KEY File exists. Skipping...";
        fi;
