docker-compose-development
docker-compose-development copied to clipboard
Speed up PHP, remove debugging features
Hi,
we are in the process of setting up a Magento2 v 2.4.3 frontend development environment.
We are quite happy and everything works, we are using php74. But we would like to speed up loading times for Magento.
We are not developing PHP modules, our development process relies on CSS and some Javascript.
We tried to disable xdebug, see last line xdebug.mode=off
. (We had also increased memory limit to 4096M):
$ cat build/custom/php/conf/php.ini
sendmail_path = "/usr/bin/msmtp --host=mailcatch --port=1025 -f [email protected] -t "
upload_max_filesize = 64M
memory_limit = 4096M
log_errors = 1
error_reporting = E_ALL
xdebug.client_host = 172.17.0.1
xdebug.discover_client_host = true
xdebug.max_nesting_level = 1024
xdebug.mode=off
In docker-compose.yml we changed the context from dist
to custom
:
php74:
build:
context: build/custom/php
...
Is this a good idea and is it the right way to do it? What else can we do to make loading times faster in our dev process? Some PHP tweaking?
And thank you so much for this wonderful product!
I removed blackfire from our local container. I made a local copy of the Dockerfile into build/custom/php
:
https://github.com/JeroenBoersma/docker-php/blob/master/php74/fpm/Dockerfile
And I removed these lines in our local copy:
# Install blackfire agent
RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \
&& (curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/${VERSION} \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
&& mv /tmp/blackfire-*.so `php -r "echo ini_get('extension_dir');"`/blackfire.so \
&& docker-php-ext-enable blackfire \
&& rm /tmp/blackfire* || true)
# Enable debug extension
RUN echo "blackfire.agent_socket=tcp://blackfire:8307" > $PHP_INI_DIR/conf.d/blackfire.ini
After a local rebuild with dev down && docker-compose build php74
blackfire seems gone from our php 7.4 container.
I hope this affects both the cli and the server versions for our Magento 2 project.
Hi, thanks for reaching out, this is indeed the way to go...
A few additional tips to make updating easier...
create a docker-custom.yml
with:
services:
php74:
build: build/custom/php
this will make sure that future updates will keep working...
to fully disable the xdebug
module.
In your custom Dockerfile
create a line with:
...
RUN docker-php-ext-enable xdebug
...
=====
IIRC both blackfire and xdebug in the latest versions do not affect loadtimes a lot. Because they only kick in when explicitly are enabled form the command line or your IDE.
If you just want to test the performance in an running environment without a specific module you can also run:
dev php-ext-disable xdebug blackfire
# test to see if disabled
dev exec php74 php -m
dev exec php74 php -v
Hope this helps, cheers.
Shouldn't it be
RUN docker-php-ext-disable xdebug
to disable?
Thank you very much, I am closing this
I ended up reverting this because I had problems building the php image later.