---

webdav_id: "{{ inventory_hostname }}-webdav"

webdav_labels: [
  '"traefik.enable=true"',
  '"traefik.http.routers.{{ webdav_id }}.service={{ webdav_id }}"',
  '"traefik.http.routers.{{ webdav_id }}.rule=Host(`{{ stage_server_domain }}`)"',
  '"traefik.http.routers.{{ webdav_id }}.entrypoints=websecure"',
  '"traefik.http.routers.{{ webdav_id }}.tls=true"',
  '"traefik.http.routers.{{ webdav_id }}.tls.certresolver=letsencrypt"',
  '"traefik.http.services.{{ webdav_id }}.loadbalancer.server.port={{ service_port_webdav }}"',

  '"traefik.http.routers.{{ webdav_id }}-admin.service={{ webdav_id }}-admin"',
  '"traefik.http.routers.{{ webdav_id }}-admin.rule=Host(`{{ stage_server_domain }}`)"',
  '"traefik.http.routers.{{ webdav_id }}-admin.entrypoints=admin-service"',
  '"traefik.http.routers.{{ webdav_id }}-admin.tls=true"',
  '"traefik.http.routers.{{ webdav_id }}-admin.tls.certresolver=letsencrypt"',
  '"traefik.http.services.{{ webdav_id }}-admin.loadbalancer.server.port={{ management_port }}"',
]

webdav_docker: {
  networks: [
    {
      name: front-tier,
      external: true,
    },
  ],
  services: [
    {
      name: "{{ webdav_id }}",
      image_name: "{{ webdav_image_name }}",
      image_version: "{{ webdav_image_version }}",
      labels: "{{ webdav_labels + ( webdav_labels_additional | default([])) }}",
      restart: "{{ webdav_service_restart | default('always') }}",
      user: root,
      environment: [
        "SPRING_PROFILES_INCLUDE: \"swagger,postgres\"",
        "DATASOURCE_URL: \"jdbc:postgresql://{{ webdav_postgres_host }}:{{ service_port_postgres }}/{{ webdav_postgres_database }}?sslmode=require\"",
        "DATASOURCE_USERNAME: \"{{ webdav_postgres_username }}\"",
        "DATASOURCE_PASSWORD: \"{{ webdav_postgres_password }}\"",

        "SMA_JWT_SECRET: \"{{ webdav_jwt_secret }}\"",

        "OPENTRACING_JAEGER_ENABLED: \"{{ webdav_opentracing_jaeger_enabled | default(false) }}\"",
        "OPENTRACING_JAEGER_LOG_SPANS: \"{{ webdav_opentracing_jaeger_log_spans | default(false) }}\"",
        "OPENTRACING_JAEGER_SERVICE_NAME: \"{{ webdav_opentracing_jaeger_service_name | default(webdav_id) }}\"",
        "OPENTRACING_JAEGER_HTTP_SENDER_URL: \"{{ webdav_opentracing_jaeger_http_sender_url | default() }}\"",
      ],
      networks: [
        '"front-tier"',
      ],
      extra_hosts: "{{ webdav_extra_hosts | default([]) }}",
    },
  ],
}
