{% include 'roles/docker-compose/templates/base.yml.j2' %}

  taiga-back:
{% include 'roles/docker-container/templates/base.yml.j2' %}
    image: "{{taiga_image_backend}}:{{ taiga_version }}"
    volumes:
      # These volumens will be used by taiga-back and taiga-async.
      - static-data:/taiga-back/static
      - media-data:/taiga-back/media
      # - ./config.py:/taiga-back/settings/config.py

{% if applications | get_app_conf(application_id, 'features.oidc', False) and applications | get_app_conf(application_id, 'oidc.flavor', True) == 'taigaio' %}

      - {{ docker_compose.directories.config }}taiga-local.py:/taiga-back/settings/local.py:ro

{% endif %}

{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:
{% include 'roles/docker-container/templates/depends_on/dmbs_incl.yml.j2' %}
      taiga-events-rabbitmq:
        condition: service_started
      taiga-async-rabbitmq:
        condition: service_started
{% if applications | get_app_conf(application_id, 'features.oidc', False) and applications | get_app_conf(application_id, 'oidc.flavor', True) == 'taigaio' %}
    
    command: >
      /bin/sh -c "
        pip install taiga-contrib-oidc-auth &&
        /taiga-back/docker/entrypoint.sh"

{% endif %}


  taiga-async:
{% include 'roles/docker-container/templates/base.yml.j2' %}
    image: "{{taiga_image_backend}}:{{ taiga_version }}"
    entrypoint: ["/taiga-back/docker/async_entrypoint.sh"]
    volumes:
      # These volumens will be used by taiga-back and taiga-async.
      - static-data:/taiga-back/static
      - media-data:/taiga-back/media
      # - ./config.py:/taiga-back/settings/config.py

{% if applications | get_app_conf(application_id, 'features.oidc', False) and applications | get_app_conf(application_id, 'oidc.flavor', True) == 'taigaio' %}

{% for item in settings_files %}
      - {{ docker_compose.directories.config }}taiga-{{ item }}.py:/taiga-back/settings/{{ item }}.py:ro
{% endfor %}

{% endif %}

{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:
{% include 'roles/docker-container/templates/depends_on/dmbs_incl.yml.j2' %}
      taiga-events-rabbitmq:
        condition: service_started
      taiga-async-rabbitmq:
        condition: service_started
{% if applications | get_app_conf(application_id, 'features.oidc', False) and applications | get_app_conf(application_id, 'oidc.flavor', True) == 'taigaio' %}
    
    command: >
      /bin/sh -c "
        pip install taiga-contrib-oidc-auth &&
        /taiga-back/docker/entrypoint.sh"
        
{% endif %}

  taiga-async-rabbitmq:
    image: rabbitmq:3.8-management-alpine
    hostname: "taiga-async-rabbitmq"
    volumes:
      - async-rabbitmq-data:/var/lib/rabbitmq
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:

  taiga-front:
    image: "{{taiga_image_frontend}}:{{ taiga_version }}"
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:
#    volumes:
#      - {{ taiga_frontend_conf_path }}:/usr/share/nginx/html/conf.json:ro

  taiga-events:
    image: taigaio/taiga-events:latest
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:
    depends_on:
      taiga-events-rabbitmq:
        condition: service_started

  taiga-events-rabbitmq:
    image: rabbitmq:3.8-management-alpine
    hostname: "events-rabbitmq"
    volumes:
      - events-rabbitmq-data:/var/lib/rabbitmq
{% include 'roles/docker-container/templates/base.yml.j2' %}

{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:

  taiga-protected:
    image: taigaio/taiga-protected:latest
{% include 'roles/docker-container/templates/base.yml.j2' %}

{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:

  taiga-gateway:
    image: nginx:alpine
    ports:
      - "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
    volumes:
      - {{docker_repository_path}}taiga-gateway/taiga.conf:/etc/nginx/conf.d/default.conf
      - static-data:/taiga/static
      - media-data:/taiga/media
{% include 'roles/docker-container/templates/base.yml.j2' %}

{% include 'roles/docker-container/templates/networks.yml.j2' %}
      taiga:
    depends_on:
      - taiga-front
      - taiga-back
      - taiga-events

{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
  static-data:
  media-data:
  async-rabbitmq-data:
  events-rabbitmq-data:

{% include 'roles/docker-compose/templates/networks.yml.j2' %}
  taiga: