Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docker]Configure opcache for dev and prod environment #837

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ COPY --from=php_extension_installer /usr/bin/install-php-extensions /usr/local/b
RUN install-php-extensions apcu curl exif gd iconv intl mbstring pdo_mysql opcache xml zip

COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY docker/php/php.ini /usr/local/etc/php/php.ini
COPY docker/php/php-cli.ini /usr/local/etc/php/php-cli.ini
COPY docker/php/prod/php.ini $PHP_INI_DIR/php.ini
COPY docker/php/prod/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini

# copy file required by opcache preloading
COPY config/preload.php /srv/sylius/config/preload.php

# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
Expand Down Expand Up @@ -121,6 +124,9 @@ COPY --from=sylius_node /srv/sylius/public public/

FROM sylius_php_prod AS sylius_php_dev

COPY docker/php/dev/php.ini $PHP_INI_DIR/php.ini
COPY docker/php/dev/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini

WORKDIR /srv/sylius

ARG APP_ENV=dev
Expand Down
5 changes: 5 additions & 0 deletions config/preload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php';
}
10 changes: 10 additions & 0 deletions docker/php/dev/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=1
opcache.revalidate_freq=0
opcache.jit=1255
opcache.jit_buffer_size=128M
opcache.interned_strings_buffer=16
7 changes: 7 additions & 0 deletions docker/php/dev/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
memory_limit=3G
post_max_size=6M
upload_max_filesize=5M
realpath_cache_size=4096K
realpath_cache_ttl=600

date.timezone=${PHP_DATE_TIMEZONE}
16 changes: 0 additions & 16 deletions docker/php/php-cli.ini

This file was deleted.

15 changes: 0 additions & 15 deletions docker/php/php.ini

This file was deleted.

11 changes: 11 additions & 0 deletions docker/php/prod/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
opcache.preload=/srv/sylius/config/preload.php
opcache.preload_user=www-data
opcache.jit=1255
opcache.jit_buffer_size=128M
opcache.interned_strings_buffer=16
7 changes: 7 additions & 0 deletions docker/php/prod/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
memory_limit=256M
post_max_size=6M
upload_max_filesize=5M
realpath_cache_size=4096K
realpath_cache_ttl=600

date.timezone=${PHP_DATE_TIMEZONE}