Downgrade Composer upon docker-compose up

Hi!

I’m currently setting up a Devilbox container with Magento 2.

Magento 2 doesn’t (yet) support Composer 2, which comes pre-installed with Devilbox. So, everytime after closing the container (docker-compose down) and booting it up (docker-compose up) I have to run composer self-update --1, before being able to do any composer related actions.

Is there a way to run this while booting up the container? I checked the documentation, because I was hoping that it’d be a matter of changing an environment variable (just like MySQL and PHP, etc.) but I don’t think it is, is it?

Thanks a lot in advance.

All the best,

Daan

You can add a file in cfg/php-startup-7.x/set_composer_v1.sh (select your PHP version) with this content:

!/bin/bash
#
# This script will automatically downgrade composer to version 1.
#

composer self-update --1

Script will be executed any time you (re)start the PHP container via docker-composer up (remember to clear configuration with docker-compose stop && docker-compose rm -f).

Hope this helps,
Max