image:
  repository: wger/server
  tag: latest@sha256:3433526ecfc00c1733914e4e836cb2b97be90dc4b1f5534a93abded77629ef4e
  pullPolicy: IfNotPresent

nginxImage:
  repository: tccr.io/truecharts/nginx
  tag: v1.23.0@sha256:4545dec2db20dd215a48d03ff65887cd4abae935f6876cd1f8d0d44a3b6ced32

securityContext:
  runAsNonRoot: false
  readOnlyRootFilesystem: false

podSecurityContext:
  runAsUser: 1000
  runAsGroup: 1000
  fsGroup: 1000

env:
  DJANGO_DB_ENGINE: "django.db.backends.postgresql"
  DJANGO_DB_DATABASE: "{{ .Values.postgresql.postgresqlDatabase }}"
  DJANGO_DB_USER: "{{ .Values.postgresql.postgresqlUsername }}"
  DJANGO_DB_PORT: "5432"
  DJANGO_DB_HOST:
    secretKeyRef:
      name: dbcreds
      key: plainhost
  DJANGO_DB_PASSWORD:
    secretKeyRef:
      name: dbcreds
      key: postgresql-password
  DJANGO_CACHE_BACKEND: "django_redis.cache.RedisCache"
  DJANGO_CACHE_CLIENT_CLASS: "django_redis.client.DefaultClient"
  DJANGO_CACHE_TIMEOUT: "1296000"
  DJANGO_CACHE_LOCATION:
    secretKeyRef:
      name: rediscreds
      key: url
  SECRET_KEY:
    secretKeyRef:
      name: wger-secrets
      key: SECRET_KEY
  TIME_ZONE: "{{ .Values.TZ }}"
  # True, not true
  WGER_USE_GUNICORN: "True"
  SITE_URL: "{{ .Values.wger.site_url }}"
  # User Defined
  FROM_EMAIL: "{{ .Values.wger.from_email }}"
  EXERCISE_CACHE_TTL: "{{ .Values.wger.exercise_cache_ttl }}"
  EMAIL_HOST: "{{ .Values.wger.email_host }}"
  EMAIL_PORT: "{{ .Values.wger.email_port }}"
  EMAIL_HOST_USER: "{{ .Values.wger.email_host_user }}"
  EMAIL_HOST_PASSWORD: "{{ .Values.wger.email_host_password }}"
  RECAPTCHA_PUBLIC_KEY: "{{ .Values.wger.recaptha_public_key }}"
  RECAPTCHA_PRIVATE_KEY: "{{ .Values.wger.recaptha_private_key }}"

envFrom:
  - configMapRef:
      name: '{{ include "tc.common.names.fullname" . }}-wger'

wger:
  # Where the backend will listen. Leave this as is, unless nginx is removed
  site_url: "http://localhost:8000"
  sync_exercises_on_startup: false
  download_exercise_images_on_startup: false
  allow_registration: true
  allow_guest_users: true
  allow_upload_videos: true
  exercise_cache_ttl: "3600"
  django_perform_migrations: true
  django_debug: false
  enable_email: false
  from_email: ""
  email_host: ""
  email_port: "587"
  email_host_user: ""
  email_host_password: ""
  email_use_tls: true
  email_use_ssl: true
  recaptha_public_key: ""
  recaptha_private_key: ""
  nocaptcha: true

configmap:
  wger:
    enabled: true
    data:
      SYNC_EXERCISES_ON_STARTUP: "{{ ternary \"True\" \"False\" .Values.wger.sync_exercises_on_startup }}"
      DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP: "{{ ternary \"True\" \"False\" .Values.wger.download_exercise_images_on_startup }}"
      ALLOW_REGISTRATION: "{{ ternary \"True\" \"False\" .Values.wger.allow_registration }}"
      ALLOW_GUEST_USERS: "{{ ternary \"True\" \"False\" .Values.wger.allow_guest_users }}"
      ALLOW_UPLOAD_VIDEOS: "{{ ternary \"True\" \"False\" .Values.wger.allow_upload_videos }}"
      DJANGO_PERFORM_MIGRATIONS: "{{ ternary \"True\" \"False\" .Values.wger.django_perform_migrations }}"
      DJANGO_DEBUG: "{{ ternary \"True\" \"False\" .Values.wger.django_debug }}"
      ENABLE_EMAIL: "{{ ternary \"True\" \"False\" .Values.wger.enable_email }}"
      EMAIL_USE_TLS: "{{ ternary \"True\" \"False\" .Values.wger.email_use_tls }}"
      EMAIL_USE_SSL: "{{ ternary \"True\" \"False\" .Values.wger.email_use_ssl }}"
      NOCAPTCHA: "{{ ternary \"True\" \"False\" .Values.wger.nocaptcha }}"
  config:
    enabled: true
    data:
      nginx-config: |-
        upstream wger {
            server localhost:8000;
        }
        server {
            listen 80;
            location / {
                proxy_pass http://localhost:8000;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_redirect off;
            }
            location /static/ {
                alias /static/;
            }
            location /media/ {
                alias /media/;
            }
            # Increase max body size to allow for video uploads
            client_max_body_size 100M;
        }

service:
  main:
    ports:
      main:
        port: 10249
        targetPort: 80

additionalContainers:
  nginx:
    name: nginx
    image: "{{ .Values.nginxImage.repository }}:{{ .Values.nginxImage.tag }}"
    ports:
      - containerPort: 80
        name: main
    securityContext:
      runAsUser: 0
      runAsGroup: 1000
      readOnlyRootFilesystem: false
      runAsNonRoot: false
    volumeMounts:
    - name: wger-config
      mountPath: "/etc/nginx/conf.d/default.conf"
      subPath: nginx-config
      readOnly: true
    - name: media
      mountPath: "/media"
    - name: static
      mountPath: "/static"

persistence:
  media:
    enabled: true
    mountPath: "/home/wger/media"
  static:
    enabled: true
    type: emptyDir
    mountPath: "/home/wger/static"
  wger-config:
    enabled: "true"
    mountPath: "/etc/nginx/conf.d/default.conf"
    subPath: "default.conf"
    type: "custom"
    volumeSpec:
      configMap:
        name: '{{ printf "%v-config" (include "tc.common.names.fullname" .) }}'

postgresql:
  enabled: true
  existingSecret: "dbcreds"
  postgresqlUsername: wger
  postgresqlDatabase: wger

redis:
  enabled: true
  existingSecret: "rediscreds"
  redisUsername: "default"
