# @todo Test which containers can be removed crom cental_database networks
x-op-app: &app
  logging:
    driver: journald
  image: {{ openproject_custom_image }}
  build:
    context: .
    dockerfile: Dockerfile

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

  cache:
    image: "{{ openproject_cache_image}}:{{ openproject_cache_version }}"
    container_name: {{ openproject_cache_name }}
{% include 'roles/docker-container/templates/base.yml.j2' %}

  proxy:
{% include 'roles/docker-container/templates/base.yml.j2' %}
    image: {{ openproject_custom_image }}
    container_name: {{ openproject_proxy_name }}
    command: "./docker/prod/proxy"
    ports:
      - "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
    environment:
      APP_HOST: web
    depends_on:
      - web
    volumes:
      - "data:/var/openproject/assets"
      - "{{ openproject_dummy_volume }}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes

  web:
    <<: *app
{% include 'roles/docker-container/templates/base.yml.j2' %}
    command: "./docker/prod/web"
    container_name: {{ openproject_web_name }}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on/dmbs_incl.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
{% set container_port = 8080 %}
{% set container_healthcheck = 'health_checks/default' %}
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
    volumes:
      - "data:/var/openproject/assets"
      - "{{ openproject_dummy_volume }}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes
      
  worker:
    <<: *app
{% include 'roles/docker-container/templates/base.yml.j2' %}
    command: "./docker/prod/worker"
    container_name: {{ openproject_worker_name }}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on/dmbs_incl.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
    volumes:
      - "data:/var/openproject/assets"
      - "{{ openproject_dummy_volume }}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes


  cron:
    <<: *app
{% include 'roles/docker-container/templates/base.yml.j2' %}
    command: "./docker/prod/cron"
    container_name: {{ openproject_cron_name }}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
{% include 'roles/docker-container/templates/depends_on/dmbs_incl.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
    volumes:
      - "data:/var/openproject/assets"
      - "{{ openproject_dummy_volume }}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes

  seeder:
    <<: *app
    command: "./docker/prod/seeder"
    container_name: {{ openproject_seeder_name }}
    env_file:
      - "{{ docker_compose.files.env }}"
    logging:
      driver: journald
    restart: on-failure
{% include 'roles/docker-container/templates/networks.yml.j2' %}
    volumes:
      - "data:/var/openproject/assets"
      - "{{ openproject_dummy_volume }}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes

{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
  data:
    name: {{ openproject_volume }}

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