services:

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

  web:
    image: espocrm/espocrm:{{ applications.espocrm.version }}
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/"]
    ports:
      - "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
{% include 'templates/docker/container/depends-on-just-database.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
    volumes:
      - data:/var/www/html

  daemon:
    image: espocrm/espocrm:{{ applications.espocrm.version }}
    restart: {{docker_restart_policy}}
    logging:
      driver: journald
    entrypoint: docker-daemon.sh
{% include 'templates/docker/container/networks.yml.j2' %}
    volumes:
      - data:/var/www/html

  websocket:
    image: espocrm/espocrm:{{ applications.espocrm.version }}
    restart: {{docker_restart_policy}}
    logging:
      driver: journald
    environment:
      - ESPOCRM_CONFIG_USE_WEB_SOCKET=true
      - ESPOCRM_CONFIG_WEB_SOCKET_URL=ws://{{ domains[application_id] }}/ws
      - ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBSCRIBER_DSN=tcp://*:7777
      - ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN=tcp://websocket:7777
    entrypoint: docker-websocket.sh
{% include 'templates/docker/container/depends-on-just-database.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
    volumes:
      - data:/var/www/html
    ports:
      - "127.0.0.1:{{ ports.localhost.websocket[application_id] }}:8080"

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

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