Add dynamic PHP error handling config for SuiteCRM:

- Introduce env-aware php.ini.j2 template
- Mount PHP config into container via docker-compose
- Add SUITECRM_PHP_CONFIG_HOST and SUITECRM_WELL_SOFTWARE_NAME variables
- Refactor LDAP extension path using normalized software name

https://chatgpt.com/share/69284194-cf6c-800f-b138-eb6ddf25592c
This commit is contained in:
2025-11-27 13:18:50 +01:00
parent bbebf7964d
commit 4f48cf633b
4 changed files with 27 additions and 1 deletions

View File

@@ -4,6 +4,13 @@
vars: vars:
docker_compose_flush_handlers: false docker_compose_flush_handlers: false
- name: "Deploy PHP error configuration (env aware)"
template:
src: "php.ini.j2"
dest: "{{ SUITECRM_PHP_CONFIG_HOST }}"
notify:
- docker compose up
- name: "Render SuiteCRM LDAP mapping" - name: "Render SuiteCRM LDAP mapping"
template: template:
src: ldap.yaml.j2 src: ldap.yaml.j2

View File

@@ -16,6 +16,7 @@
{% include 'roles/docker-container/templates/networks.yml.j2' %} {% include 'roles/docker-container/templates/networks.yml.j2' %}
volumes: volumes:
- data:/var/www/html/ - 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 %} {% if SUITECRM_LDAP_ENABLED | bool %}
# Readonly isn't possible for LDAP config, because otherwise file permission script will fail # Readonly isn't possible for LDAP config, because otherwise file permission script will fail

View File

@@ -0,0 +1,14 @@
; Dynamic error reporting based on ENVIRONMENT
; Rendered by Ansible/Jinja2 at deploy time.
{% if (ENVIRONMENT | lower) == 'development' %}
display_errors = On
display_startup_errors = On
log_errors = On
error_reporting = E_ALL
{% else %}
display_errors = Off
display_startup_errors = Off
log_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
{% endif %}

View File

@@ -9,6 +9,10 @@ database_type: "mariadb"
# Webserver # Webserver
client_max_body_size: "100m" client_max_body_size: "100m"
# General
SUITECRM_WELL_SOFTWARE_NAME: "{{ SOFTWARE_NAME | lower | replace('.', '-') }}"
SUITECRM_PHP_CONFIG_HOST: "{{ [ docker_compose.directories.config, 'php.ini'] | path_join }}"
# Container images # Container images
# Base PHP image used to run SuiteCRM # Base PHP image used to run SuiteCRM
SUITECRM_BASE_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.' ~ entity_name ~ '.image') }}" SUITECRM_BASE_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.' ~ entity_name ~ '.image') }}"
@@ -29,7 +33,7 @@ SUITECRM_URL: "{{ domains | get_url(application_id, WEB_
# LDAP # LDAP
SUITECRM_LDAP_ENABLED: "{{ applications | get_app_conf(application_id, 'features.ldap') }}" SUITECRM_LDAP_ENABLED: "{{ applications | get_app_conf(application_id, 'features.ldap') }}"
SUITECRM_LDAP_CONFIG_HOST: "{{ [ docker_compose.directories.config, 'ldap.yaml'] | path_join }}" SUITECRM_LDAP_CONFIG_HOST: "{{ [ docker_compose.directories.config, 'ldap.yaml'] | path_join }}"
SUITECRM_LDAP_EXTENSION_DIR: "/var/www/html/extensions/{{ SOFTWARE_NAME | lower | replace('.', '-') }}/config/services/ldap" SUITECRM_LDAP_EXTENSION_DIR: "{{ ['/var/www/html/extensions', SUITECRM_WELL_SOFTWARE_NAME, 'config/services/ldap'] | path_join }}"
# Simple maintenance toggle (for later extensions) # Simple maintenance toggle (for later extensions)
SUITECRM_INIT_MAINTENANCE_MODE: "{{ applications | get_app_conf(application_id, 'maintenance_mode') }}" SUITECRM_INIT_MAINTENANCE_MODE: "{{ applications | get_app_conf(application_id, 'maintenance_mode') }}"