From 1c2df4e20b6a9b86a5ccad6bc77152c63d21fdcd Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Mon, 31 Mar 2025 14:25:44 +0200 Subject: [PATCH] Prod perfomance optimizations --- .env.prod.sample | 2 +- docker/entrypoint.sh | 22 +++++++++++++++++++--- memcached.yml | 13 +++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 memcached.yml diff --git a/.env.prod.sample b/.env.prod.sample index 4b66ef9..c4ec35c 100644 --- a/.env.prod.sample +++ b/.env.prod.sample @@ -1,4 +1,4 @@ -COMPOSE_FILE=docker-compose.yml:traefik.yml:expose_mariadb.yml +COMPOSE_FILE=docker-compose.yml:traefik.yml:expose_mariadb.yml:memcached.yml # TRAEFIK CONFIG HOST=dolibarr.FQDN diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4a3709b..bdc067f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -10,10 +10,26 @@ git fetch git checkout $DOLI_VERSION if [ "$ENV" == "prod" ]; then sed -i '/\(xdebug.*\)/d' /etc/php/$PHP_VER/fpm/conf.d/00-dolibarr.ini - sed -i '/\(xdebug.*\)/d' /etc/php/$PHP_VER/cli/conf.d/00-dolibarr.ini sed -i '/error/d' /etc/php/$PHP_VER/fpm/conf.d/00-dolibarr.ini - sed -i '/error/d' /etc/php/$PHP_VER/cli/conf.d/00-dolibarr.ini - apt-get purge -y php-xdebug + apt-get purge -y php-xdebug php$PHP_VER-xdebug + apt-get install -y php-opcache php-memcached + cat <<EOF>>/etc/php/$PHP_VER/fpm/conf.d/00-dolibarr.ini +; Enable Opcache +opcache.enable=1 +; Set the memory size for the Opcache (e.g., 128MB) +opcache.memory_consumption=512 +; Set the maximum number of scripts to cache +opcache.max_accelerated_files=10000 +; Set the cache validity time in seconds +opcache.revalidate_freq=2 +; Enable file validation for updated scripts +opcache.validate_timestamps=1 +; Set the timeout for a request before it is terminated +opcache.max_file_size=2M +; Enable opcache for the CLI +opcache.enable_cli=1 +EOF + cp /etc/php/$PHP_VER/fpm/conf.d/00-dolibarr.ini /etc/php/$PHP_VER/cli/conf.d/00-dolibarr.ini fi echo "*/5 * * * * www-data /usr/bin/php /var/www/dolibarr/scripts/cron/cron_run_jobs.php $CRON_KEY $CRON_USER > /var/www/dolibarr/documents/cron_run_jobs.php.log" >> /etc/crontab php-fpm$PHP_VER -D diff --git a/memcached.yml b/memcached.yml new file mode 100644 index 0000000..5d1cfc6 --- /dev/null +++ b/memcached.yml @@ -0,0 +1,13 @@ +services: + dolibarr: + depends_on: + memcached: + condition: service_started + + memcached: + image: memcached + command: + - --conn-limit=1024 + - --memory-limit=64 + - --threads=4 + -- GitLab