{% include 'roles/docker-compose/templates/base.yml.j2' %}
  web:
    container_name: {{ espocrm_name }}
    image: "{{ espocrm_image }}:{{ espocrm_version }}"
{% include 'roles/docker-container/templates/base.yml.j2' %}
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
    ports:
      - "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
    volumes:
      - data:/var/www/html

  daemon:
    image: "{{ espocrm_image }}:{{ espocrm_version }}"
    restart: {{ DOCKER_RESTART_POLICY }}
    logging:
      driver: journald
    entrypoint: docker-daemon.sh
{% include 'roles/docker-container/templates/networks.yml.j2' %}
    volumes:
      - data:/var/www/html

  websocket:
    image: "{{ espocrm_image }}:{{ espocrm_version }}"
    restart: {{ DOCKER_RESTART_POLICY }}
    logging:
      driver: journald
    environment:
      - ESPOCRM_CONFIG_USE_WEB_SOCKET=true
      - ESPOCRM_CONFIG_WEB_SOCKET_URL=wss://{{ domains | get_domain(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 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
    volumes:
      - data:/var/www/html
    ports:
      - "127.0.0.1:{{ ports.localhost.websocket[application_id] }}:8080"

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

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