---

wordpress_labels: [
  '"traefik.enable=true"',
  '"traefik.http.routers.{{ wordpress_id }}.service={{ wordpress_id }}"',
  '"traefik.http.routers.{{ wordpress_id }}.rule=Host(`{{ wordpress_base_url }}`)"',
  '"traefik.http.routers.{{ wordpress_id }}.entrypoints=websecure"',
  '"traefik.http.routers.{{ wordpress_id }}.tls=true"',
  '"traefik.http.routers.{{ wordpress_id }}.tls.certresolver=letsencrypt"',
  '"traefik.http.services.{{ wordpress_id }}.loadbalancer.server.port=80"',
]

wordpress_docker: {
  networks: [
    {
      name: back-tier,
      external: true,
    },
    {
      name: front-tier,
      external: true,
    },
  ],
  volumes: [
    {
      name: "{{ wordpress_id }}-content"
    },
  ],
  services: [
    {
      name: "{{ wordpress_id }}",
      image_name: "{{ wordpress_image_name }}",
      image_version: "{{ wordpress_image_version }}",
      labels: "{{ wordpress_labels + ( wordpress_labels_additional | default([])) }}",
      environment: [
        "WORDPRESS_DB_HOST: \"{{ connect_wordpress_maria_host }}:{{ wordpress_mysql_port | default('3306') }}\"",
        "WORDPRESS_DB_USER: \"{{ connect_wordpress_maria_username }}\"",
        "WORDPRESS_DB_PASSWORD: \"{{ connect_wordpress_maria_password }}\"",
        "WORDPRESS_DB_NAME: \"{{ connect_wordpress_maria_database }}\"",
        "WORDPRESS_DEBUG: \"{{ wordpress_debug | default(1) }}\"",
        "WORDPRESS_DOMAIN: \"{{ http_s }}://{{ wordpress_base_url }}\"",
        "WORDPRESS_CONFIG_EXTRA: |",
        "  define( 'WP_HOME', 'https://{{ wordpress_base_url }}' );",
        "  define( 'WP_SITEURL', 'https://{{ wordpress_base_url }}' );",
        "  define( 'MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT );",
        "AUTH_API: \"https://{{ shared_service_hostname_keycloak }}\"",
        "RESOURCE_API: \"https://{{ connect_base_url }}\"",
        "REALM_ID: \"{{ current_realm_name }}\"",
        "REGISTRATION_ID: \"{{ connect_wordpress_oidc_client_id }}\"",
        "CLIENT_ID: \"{{ connect_wordpress_oidc_client_id }}\"",
        "CLIENT_SECRET: \"{{ connect_wordpress_oidc_client_secret }}\"",
        "CLIENT_USERNAME: \"{{ connect_wordpress_buergerportal_username }}\"",
        "CLIENT_PASSWORD: \"{{ connect_wordpress_buergerportal_password }}\"",
        "SK_NRW_ISSUER: \"{{ connect_wordpress_oidc_issuer }}\"",
        "SK_NRW_PROVIDER_URL: \"{{ connect_wordpress_oidc_provider_url }}\"",
        "SK_NRW_CLIENT_ID: \"{{ connect_wordpress_oidc_client_id }}\"",
        "SK_NRW_CLIENT_SECRET: \"{{ connect_wordpress_oidc_client_secret }}\"",
        "SMARDIGO_AUTH_TOKEN_NAME: \"{{ smardigo_auth_token_name }}\"",
        "SMARDIGO_AUTH_TOKEN_VALUE: \"{{ smardigo_auth_token_value }}\"",
      ],
      volumes: [
        '"{{ wordpress_id }}-content:/var/www/html/wp-content"',
      ],
      networks: [
        '"back-tier"',
        '"front-tier"',
      ],
      extra_hosts: "{{ wordpress_extra_hosts | default([]) }}",
    },
  ],
}
