How to unlimit PHP Deployer composer memory?

763 views Asked by At

I am running PHP deployer for a magento application from a docker-compose. The apache is inside a container and there is a memory limit for php. I have control on the Dockerfile, if needed.

Currently my issue is that when I run dep deploy it crashes:

$ dep deploy 
✈︎ Deploying master on main
✔ Executing task deploy:prepare
✔ Executing task deploy:lock
✔ Executing task deploy:release
✔ Executing task deploy:update_code
✔ Executing task deploy:shared
➤ Executing task deploy:vendors
✔ Executing task deploy:failed
✔ Executing task deploy:unlock

In Client.php line 103:
                                                                                                                                                                                                                         
  The command "cd /home/public_html/releases/20201214130007 && /usr/local/bin/composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest" failed.  
                                                                                                                                                                                                                         
  Exit Code: 255 (Unknown error)                                                                                                                                                                                         
                                                                                                                                                                                                                         

If I run the composer line inside the container with the addition of unlimit of the memory, it works:

php -d memory_limit=-1 /usr/local/bin/composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest

I tried to force to force deployer to use to use composer this way, but it didn't work:

# in deployer.php:
set('composer', 'php -d memory_limit=-1  /usr/local/bin/composer');

I think that it is because it is not using the composer from the set when doing deployer:vendors as can be seen from the verbose log:

➤ Executing task deploy:vendors
[main] > if hash unzip 2>/dev/null; then echo 'true'; fi
[main] < true
[main] > if hash composer 2>/dev/null; then echo 'true'; fi
[main] < true
[main] > command -v 'composer' || which 'composer' || type -p 'composer'
[main] < /usr/local/bin/composer
[main] > cd /home/public_html/releases/20201214125356 && /usr/local/bin/composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest

Any suggestions how to fix this?

1

There are 1 answers

0
edvordo On BEST ANSWER

To change the composer binary used by deployer, you need to set bin/composer, so change this

set('composer', 'php -d memory_limit=-1  /usr/local/bin/composer');

to this

set('bin/composer', 'php -d memory_limit=-1  /usr/local/bin/composer');