Skip to content

Commit

Permalink
Merge pull request #10 from outlandishideas/use-opcache
Browse files Browse the repository at this point in the history
Enable + configure opcache; tidy up PHP config overrides
  • Loading branch information
rasmuswinter authored Apr 27, 2023
2 parents 6605285 + e6c70e0 commit 19c39d9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
34 changes: 34 additions & 0 deletions php-custom.ini
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions php7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 3 additions & 4 deletions php8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 3 additions & 4 deletions php8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 3 additions & 4 deletions php8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 19c39d9

Please sign in to comment.