From b34f7b3961a86b8589f837b91e5a5d149914b8ba Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Thu, 22 May 2025 19:48:11 +0200 Subject: [PATCH] Enhance PHP Configuration Defaults in Docker Entrypoint - Updated the `php-fpm-entrypoint` script to set default values for PHP configuration settings, including `memory_limit`, `max_execution_time`, `upload_max_filesize`, and `post_max_size`, when not explicitly provided through environment variables. This change ensures that the application has sensible defaults, improving reliability and reducing potential misconfigurations during deployment. These modifications aim to enhance the Docker setup by providing fallback values for critical PHP settings, thereby streamlining the configuration process and ensuring better performance in various environments. --- docker/php-fpm-entrypoint | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docker/php-fpm-entrypoint b/docker/php-fpm-entrypoint index ff120389..6feb2940 100644 --- a/docker/php-fpm-entrypoint +++ b/docker/php-fpm-entrypoint @@ -54,24 +54,32 @@ apply_php_configuration() { # Create custom PHP config file PHP_CUSTOM_CONFIG_FILE="/usr/local/etc/php/conf.d/99-custom.ini" - # Apply memory limit if provided + # Apply memory limit if provided, otherwise default to 1G if [ -n "$PHP_MEMORY_LIMIT" ]; then echo "memory_limit = $PHP_MEMORY_LIMIT" >> $PHP_CUSTOM_CONFIG_FILE + else + echo "memory_limit = 1G" >> $PHP_CUSTOM_CONFIG_FILE fi - # Apply max execution time if provided + # Apply max execution time if provided, otherwise default to 300s if [ -n "$PHP_MAX_EXECUTION_TIME" ]; then echo "max_execution_time = $PHP_MAX_EXECUTION_TIME" >> $PHP_CUSTOM_CONFIG_FILE + else + echo "max_execution_time = 300" >> $PHP_CUSTOM_CONFIG_FILE fi - # Apply upload max filesize if provided + # Apply upload max filesize if provided, otherwise default to 50M if [ -n "$PHP_UPLOAD_MAX_FILESIZE" ]; then echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE" >> $PHP_CUSTOM_CONFIG_FILE + else + echo "upload_max_filesize = 50M" >> $PHP_CUSTOM_CONFIG_FILE fi - # Apply post max size if provided + # Apply post max size if provided, otherwise default to 55M if [ -n "$PHP_POST_MAX_SIZE" ]; then echo "post_max_size = $PHP_POST_MAX_SIZE" >> $PHP_CUSTOM_CONFIG_FILE + else + echo "post_max_size = 55M" >> $PHP_CUSTOM_CONFIG_FILE fi # Log applied configuration