From e6c70e0ca1056e0da440a838d9e893fab4afdbaf Mon Sep 17 00:00:00 2001 From: Noel Light-Hilary Date: Thu, 27 Apr 2023 13:46:56 +0100 Subject: [PATCH] Enable + configure opcache; tidy up PHP config overrides --- php-custom.ini | 34 ++++++++++++++++++++++++++++++++++ php7.4/Dockerfile | 7 +++---- php8.0/Dockerfile | 7 +++---- php8.1/Dockerfile | 7 +++---- php8.2/Dockerfile | 7 +++---- 5 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 php-custom.ini diff --git a/php-custom.ini b/php-custom.ini new file mode 100644 index 0000000..52fe420 --- /dev/null +++ b/php-custom.ini @@ -0,0 +1,34 @@ +; Configuration should be common to all supported PHP versions. + +date.timezone=Europe/London + +session.autostart=0 + +post_max_size=16M +upload_max_filesize=16M + +; See https://secure.php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files +; and https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html +opcache.max_accelerated_files = 7963 + +; Support very small ECS tasks, but increase slightly from default 128MB. +opcache.memory_consumption = 192 + +; Increase from default 8MB +opcache.interned_strings_buffer = 32 + +; As recommended by https://secure.php.net/manual/en/opcache.installation.php and +; https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html +opcache.fast_shutdown = 1 + +; Task definition artifacts are immutable on ECS and cache check time is 0 on local -> may as well make tasks faster +opcache.enable_cli = 1 + +; Note opcache.validate_timestamps = 0 is added for ECS instances by modifications in apps' own deployment +; Dockerfiles. The below is intended for development only – it re-checks files immediately – and is rendered +; redundant on ECS by that setting. +opcache.revalidate_freq = 0 + +; ECS deployments' Dockerfiles should set this additional key, but on local +; it would mean you can't see any changes as you work. +; opcache.validate_timestamps = 0 diff --git a/php7.4/Dockerfile b/php7.4/Dockerfile index 0daecac..7b2191e 100644 --- a/php7.4/Dockerfile +++ b/php7.4/Dockerfile @@ -9,10 +9,9 @@ RUN apk update \ && apk add --no-cache $PHP_GD_DEPS icu-dev \ && docker-php-ext-configure intl \ && docker-php-ext-install gd mysqli pdo pdo_mysql intl \ - && echo "date.timezone=Europe/London" > /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "session.autostart=0" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "post_max_size=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "upload_max_filesize=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini + && docker-php-ext-enable opcache + +COPY ../php-custom.ini /usr/local/etc/php/ RUN apk update && apk add --virtual --no-cache \ imagemagick imagemagick-dev $PHPIZE_DEPS \ diff --git a/php8.0/Dockerfile b/php8.0/Dockerfile index 1a64361..0b13cfd 100644 --- a/php8.0/Dockerfile +++ b/php8.0/Dockerfile @@ -11,10 +11,9 @@ RUN apk update \ && apk add --no-cache $PHP_GD_DEPS icu-dev \ && docker-php-ext-configure intl \ && docker-php-ext-install gd mysqli pdo pdo_mysql intl \ - && echo "date.timezone=Europe/London" > /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "session.autostart=0" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "post_max_size=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "upload_max_filesize=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini + && docker-php-ext-enable opcache + +COPY ../php-custom.ini /usr/local/etc/php/ RUN apk update && apk add --virtual --no-cache \ imagemagick imagemagick-dev $PHPIZE_DEPS \ diff --git a/php8.1/Dockerfile b/php8.1/Dockerfile index eff3e18..686bb55 100644 --- a/php8.1/Dockerfile +++ b/php8.1/Dockerfile @@ -9,10 +9,9 @@ RUN apk update \ && apk add --no-cache $PHP_GD_DEPS icu-dev \ && docker-php-ext-configure intl \ && docker-php-ext-install gd mysqli pdo pdo_mysql intl \ - && echo "date.timezone=Europe/London" > /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "session.autostart=0" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "post_max_size=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "upload_max_filesize=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini + && docker-php-ext-enable opcache + +COPY ../php-custom.ini /usr/local/etc/php/ RUN apk update && apk add --virtual --no-cache \ imagemagick imagemagick-dev $PHPIZE_DEPS \ diff --git a/php8.2/Dockerfile b/php8.2/Dockerfile index 98c8134..d2dd2a0 100644 --- a/php8.2/Dockerfile +++ b/php8.2/Dockerfile @@ -9,10 +9,9 @@ RUN apk update \ && apk add --no-cache $PHP_GD_DEPS icu-dev \ && docker-php-ext-configure intl \ && docker-php-ext-install gd mysqli pdo pdo_mysql intl \ - && echo "date.timezone=Europe/London" > /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "session.autostart=0" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "post_max_size=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini \ - && echo "upload_max_filesize=16M" >> /usr/local/etc/php/conf.d/zz-custom.ini + && docker-php-ext-enable opcache + +COPY ../php-custom.ini /usr/local/etc/php/ RUN apk update && apk add --virtual --no-cache \ imagemagick imagemagick-dev $PHPIZE_DEPS \