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

{% set service_name = SUITECRM_SERVICE %}
  {{ service_name }}:
    {{ lookup('template', 'roles/docker-container/templates/build.yml.j2') | indent(4) }}
    container_name: {{ SUITECRM_CONTAINER }}
    image: "{{ SUITECRM_CUSTOM_IMAGE }}"
    init: true
    stop_signal: SIGTERM
    stop_grace_period: 30s
{% 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/
      - "{{ SUITECRM_PHP_CONFIG_HOST }}:/usr/local/etc/php/conf.d/{{ SUITECRM_WELL_SOFTWARE_NAME }}.ini:ro"

{% if SUITECRM_LDAP_ENABLED | bool %}
      # Readonly isn't possible for LDAP config, because otherwise file permission script will fail
      - "{{ SUITECRM_LDAP_CONFIG_HOST }}:{{ SUITECRM_LDAP_EXTENSION_DIR }}/ldap.yaml"
{% endif %}

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

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