I'm trying to turn to Enabled "Zend OPcache - File Cache" in a docker PHP-FPM image. Currently, it's Disabled and the time to render a basic page on a Symfony website takes about 15 sec instead of 150ms.
I'm using the php-fpm-8-2-1 image on Docker which works with other containers like:
- redis
- psql
- node
- maildev
- nginx
All work fine except the php image has a part of Zend OPcache disabled.
I try multiple solutions to turn "on" the File Cache but it didn't work.
In following, there is my docker-compose file, my Dockerfile (of php) and my opcache.ini file (I have one to override the default config.
# docker-compose.yaml
version: '3.8'
networks:
dev:
services:
php-fpm:
build:
context: php/php8-2
restart: always
networks:
- dev
depends_on:
- db
volumes:
# - ./php/extensions/apcu.ini:/usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
- ./php/extensions/opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
- ./../projects/:/var/www
My PHP-FPM image build:
FROM php:8.2.1-fpm
RUN apt-get update && \
apt-get install -y --no-install-recommends vim bash-completion libssl-dev zlib1g-dev curl git unzip libxml2-dev libpq-dev libzip-dev && \
pecl install apcu xdebug-3.1.3 && \
docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \
docker-php-ext-install -j$(nproc) zip intl opcache pdo pdo_mysql pdo_pgsql pgsql && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=composer /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
CMD composer i -o ; php-fpm
EXPOSE 9000
; opcache.ini
zend_extension=opcache.so
#extension=opcache
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=50000
opcache.max_wasted_percentage=15
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=0
opcache.file_cache_fallback=1
[www]
clear_env = no
Consequences of it, my website on Symfony takes about 15 sec to render a page... Which should be render in about 150ms :(.
Can someone tell me what I'm doing wrong, please?
Thanks everyone!