services:

{% include 'roles/docker-central-database/templates/services/' + database_type + '.yml.j2' %}

  application:
    image: quay.io/keycloak/keycloak:{{applications.keycloak.version}}
    container_name: {{container_name}}
    command: start {% if applications[application_id].import_realm | bool %}--import-realm{% endif %}
    {% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    ports:
      - "127.0.0.1:{{ports.localhost.http[application_id]}}:8080"
    volumes:
      - "{{import_directory_host}}:{{import_directory_docker}}"
{% include 'templates/docker/container/depends-on-just-database.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
    healthcheck:
      test: ["CMD", "sh", "-c", "exec 3<>/dev/tcp/localhost/9000 && echo -e 'GET /health/live HTTP/1.1\\r\\nHost: {{domains.keycloak}}\\r\\nConnection: close\\r\\n\\r\\n' >&3 && cat <&3"]
      interval: 30s
      timeout: 10s
      retries: 3

{% include 'templates/docker/compose/networks.yml.j2' %}