Kevin Veen-Birkenbach 8b2f0ac47b
refactor(web-app-espocrm): improve config patching and container vars
- Replace `ESPOCRM_NAME` with `ESPOCRM_CONTAINER` for clarity and consistency.
- Drop unused `ESPOCRM_CONFIG_FILE_PUBLIC`, rely only on `config-internal.php`.
- Make DB credential patching idempotent using `grep` + `sed` checks.
- Replace direct sed edits for maintenance/cron/cache with EspoCRM ConfigWriter.
- Add fallback execution as root if www-data user cannot write config.
- Clear EspoCRM cache only when config changes and in update mode.
- Remove obsolete OIDC scopes inline task (now handled via env/vars).
- Fix docker-compose template to use `ESPOCRM_CONTAINER`.

This refactor makes the EspoCRM role more robust, idempotent, and aligned
with EspoCRM’s official ConfigWriter mechanism.

See conversation: https://chatgpt.com/share/68a87820-12f8-800f-90d6-01ba97a1b279
2025-08-22 16:01:48 +02:00

46 lines
1.7 KiB
Django/Jinja

{% include 'roles/docker-compose/templates/base.yml.j2' %}
web:
container_name: {{ ESPOCRM_CONTAINER }}
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' %}