---
- name: "include docker-central-database"
  include_role:
    name: docker-central-database

- name: "Include setup for domain '{{ domain }}'"
  include_role: 
    name: nginx-domain-setup
  vars:
    ws_path:              "/ws"
    ws_port:              "{{ ports.localhost.websocket[application_id] }}"
    client_max_body_size: "100m"
    vhost_flavour:        "ws_generic"
    domain:               "{{ domains | get_domain(application_id) }}"
    http_port:            "{{ ports.localhost.http[application_id] }}"

- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

- name: Set OIDC scopes in EspoCRM config (inside web container)
  ansible.builtin.shell: |
    docker compose exec -T web php -r '
      require "/var/www/html/bootstrap.php";
      $writer = (new \Espo\Core\Application())
        ->getContainer()
        ->get("injectableFactory")
        ->create("\Espo\Core\Utils\Config\ConfigWriter");
      $writer->set("oidcScopes", ["openid", "profile", "email"]);
      $writer->save();
    '
  args:
    chdir: "{{ docker_compose.directories.instance }}"