From 8fc8d926899b4fb75ffabc958c0e6b410a1d824c Mon Sep 17 00:00:00 2001 From: Al3x Zamponi <562324+alexz707@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:20:44 +0100 Subject: [PATCH] Update settings so they use env vars (#147) * Add php & php-fpm config via env vars * Add pid file location to supervisord config, moved to conf dir * Add env vars and copying of conf files --- Dockerfile | 35 +++++++++++++++---- files/conf/php-fpm/php-fpm.conf | 8 +++++ files/conf/php/php.ini | 14 ++++++++ files/{ => conf/supervisord}/supervisord.conf | 1 + 4 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 files/conf/php-fpm/php-fpm.conf create mode 100644 files/conf/php/php.ini rename files/{ => conf/supervisord}/supervisord.conf (64%) diff --git a/Dockerfile b/Dockerfile index 777e67d..8ca95e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,16 +45,37 @@ RUN set -eux; \ \ build-cleanup.sh; \ \ - { \ - echo "upload_max_filesize = 100M"; \ - echo "memory_limit = 256M"; \ - echo "post_max_size = 100M"; \ - } > /usr/local/etc/php/conf.d/20-pimcore.ini; \ - \ ldconfig /usr/local/lib; \ \ sync +COPY files/conf/php/php.ini /usr/local/etc/php/conf.d/20-pimcore.ini +COPY files/conf/php-fpm/php-fpm.conf /usr/local/etc/php-fpm.d/zz-www.conf + +# env php.ini +ENV PHP_MEMORY_LIMIT "256M" +ENV PHP_POST_MAX_SIZE "100M" +ENV PHP_UPLOAD_MAX_FILESIZE "100M" +ENV PHP_DISPLAY_STARTUP_ERRORS 1 +ENV PHP_MAX_EXECUTION_TIME "30" +ENV PHP_ERROR_REPORTING "E_ALL" + +# opcache settings +ENV OPCACHE_ENABLE 1 +ENV OPCACHE_ENABLE_CLI 0 +ENV OPCACHE_MEMORY_CONSUMPTION 128 +ENV OPCACHE_MAX_ACCELERATED_FILES 10000 +ENV OPCACHE_VALIDATE_TIMESTAMPS 1 +ENV OPCACHE_CONSISTENCY_CHECKS 0 + +# fpm settings +ENV PHP_FPM_PM dynamic +ENV PHP_FPM_PM_MAX_CHILDREN 5 +ENV PHP_FPM_PM_START_SERVERS 2 +ENV PHP_FPM_PM_MAX_SPARE_SERVERS 3 +ENV PHP_FPM_PM_MIN_SPARE_SERVERS 1 +ENV PHP_FPM_PM_MAX_REQUESTS 10000 + ENV COMPOSER_ALLOW_SUPERUSER 1 ENV COMPOSER_MEMORY_LIMIT -1 COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer @@ -203,6 +224,6 @@ RUN set -eux; \ chmod gu+rw /var/run; \ chmod gu+s /usr/sbin/cron -COPY files/supervisord.conf /etc/supervisor/supervisord.conf +COPY files/conf/supervisord/supervisord.conf /etc/supervisor/supervisord.conf CMD ["/usr/bin/supervisord"] diff --git a/files/conf/php-fpm/php-fpm.conf b/files/conf/php-fpm/php-fpm.conf new file mode 100644 index 0000000..700edc8 --- /dev/null +++ b/files/conf/php-fpm/php-fpm.conf @@ -0,0 +1,8 @@ +; File overwrites the original values with environment variables +[www] +pm = ${PHP_FPM_PM} +pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN} +pm.start_servers = ${PHP_FPM_PM_START_SERVERS} +pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS} +pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS} +pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS} diff --git a/files/conf/php/php.ini b/files/conf/php/php.ini new file mode 100644 index 0000000..8909ec9 --- /dev/null +++ b/files/conf/php/php.ini @@ -0,0 +1,14 @@ +memory_limit = ${PHP_MEMORY_LIMIT} +max_execution_time = ${PHP_MAX_EXECUTION_TIME} +error_reporting = ${PHP_ERROR_REPORTING} +display_errors = ${PHP_DISPLAY_ERRORS} +display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS} +post_max_size = ${PHP_POST_MAX_SIZE} +upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE} + +opcache.enable = ${OPCACHE_ENABLE} +opcache.enable_cli = ${OPCACHE_ENABLE_CLI} +opcache.memory_consumption = ${OPCACHE_MEMORY_CONSUMPTION} +opcache.max_accelerated_files = ${OPCACHE_MAX_ACCELERATED_FILES} +opcache.validate_timestamps = ${OPCACHE_VALIDATE_TIMESTAMPS} +opcache.consistency_checks = ${OPCACHE_CONSISTENCY_CHECKS} diff --git a/files/supervisord.conf b/files/conf/supervisord/supervisord.conf similarity index 64% rename from files/supervisord.conf rename to files/conf/supervisord/supervisord.conf index e59b14a..943e528 100755 --- a/files/supervisord.conf +++ b/files/conf/supervisord/supervisord.conf @@ -1,6 +1,7 @@ ; supervisor config file [supervisord] +pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=true logfile=/dev/null logfile_maxbytes=0