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.
This commit is contained in:
Julien Nahum 2025-05-22 19:48:11 +02:00
parent 7d7aba10b1
commit b34f7b3961
1 changed files with 12 additions and 4 deletions

View File

@ -54,24 +54,32 @@ apply_php_configuration() {
# Create custom PHP config file # Create custom PHP config file
PHP_CUSTOM_CONFIG_FILE="/usr/local/etc/php/conf.d/99-custom.ini" 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 if [ -n "$PHP_MEMORY_LIMIT" ]; then
echo "memory_limit = $PHP_MEMORY_LIMIT" >> $PHP_CUSTOM_CONFIG_FILE echo "memory_limit = $PHP_MEMORY_LIMIT" >> $PHP_CUSTOM_CONFIG_FILE
else
echo "memory_limit = 1G" >> $PHP_CUSTOM_CONFIG_FILE
fi fi
# Apply max execution time if provided # Apply max execution time if provided, otherwise default to 300s
if [ -n "$PHP_MAX_EXECUTION_TIME" ]; then if [ -n "$PHP_MAX_EXECUTION_TIME" ]; then
echo "max_execution_time = $PHP_MAX_EXECUTION_TIME" >> $PHP_CUSTOM_CONFIG_FILE echo "max_execution_time = $PHP_MAX_EXECUTION_TIME" >> $PHP_CUSTOM_CONFIG_FILE
else
echo "max_execution_time = 300" >> $PHP_CUSTOM_CONFIG_FILE
fi fi
# Apply upload max filesize if provided # Apply upload max filesize if provided, otherwise default to 50M
if [ -n "$PHP_UPLOAD_MAX_FILESIZE" ]; then if [ -n "$PHP_UPLOAD_MAX_FILESIZE" ]; then
echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE" >> $PHP_CUSTOM_CONFIG_FILE echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE" >> $PHP_CUSTOM_CONFIG_FILE
else
echo "upload_max_filesize = 50M" >> $PHP_CUSTOM_CONFIG_FILE
fi fi
# Apply post max size if provided # Apply post max size if provided, otherwise default to 55M
if [ -n "$PHP_POST_MAX_SIZE" ]; then if [ -n "$PHP_POST_MAX_SIZE" ]; then
echo "post_max_size = $PHP_POST_MAX_SIZE" >> $PHP_CUSTOM_CONFIG_FILE echo "post_max_size = $PHP_POST_MAX_SIZE" >> $PHP_CUSTOM_CONFIG_FILE
else
echo "post_max_size = 55M" >> $PHP_CUSTOM_CONFIG_FILE
fi fi
# Log applied configuration # Log applied configuration