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

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

{% include 'roles/docker-oauth2-proxy/templates/container.yml.j2' %}

  cache:
    image: memcached
    container_name: openproject-memcached
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}

  proxy:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: {{custom_openproject_image}}
    container_name: openproject-proxy
    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"
      - "{{dummy_volume}}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes

  web:
    <<: *app
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: "./docker/prod/web"
    container_name: openproject-web
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/container/depends-on-also-database.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health_checks/default"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 30s
    volumes:
      - "data:/var/openproject/assets"
      - "{{dummy_volume}}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes
      
  worker:
    <<: *app
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: "./docker/prod/worker"
    container_name: openproject-worker
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/container/depends-on-also-database.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
    volumes:
      - "data:/var/openproject/assets"
      - "{{dummy_volume}}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes


  cron:
    <<: *app
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: "./docker/prod/cron"
    container_name: openproject-cron
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/container/depends-on-also-database.yml.j2' %}
      cache:
        condition: service_started
      seeder:
        condition: service_started
    volumes:
      - "data:/var/openproject/assets"
      - "{{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
    env_file:
      - "{{docker_compose.files.env}}"
    logging:
      driver: journald
    restart: on-failure
{% include 'templates/docker/container/networks.yml.j2' %}
    volumes:
      - "data:/var/openproject/assets"
      - "{{dummy_volume}}:/var/openproject/pgdata" # This mount is unnecessary and just done to prevent anonymous volumes

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

{% include 'templates/docker/compose/volumes.yml.j2' %}
  data: