Add COMPOSER_EXTRA_PACKAGES env var for runtime package installation in Docker (#1138)

* Initial plan

* Add COMPOSER_EXTRA_PACKAGES environment variable support for Docker containers

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Add shellcheck disable comment for intentional word splitting

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Add documentation for installing mailer packages in email.md

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Add --no-dev flag to composer require to prevent dev packages installation

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

* Use --no-install with require and run separate install command

Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
This commit is contained in:
Copilot 2025-12-07 18:38:59 +01:00 committed by GitHub
parent 60ff727896
commit 0ac23cdf21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 147 additions and 2 deletions

View file

@ -26,6 +26,28 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
composer install --prefer-dist --no-progress --no-interaction
fi
# Install additional composer packages if COMPOSER_EXTRA_PACKAGES is set
if [ -n "$COMPOSER_EXTRA_PACKAGES" ]; then
echo "Installing additional composer packages: $COMPOSER_EXTRA_PACKAGES"
# Note: COMPOSER_EXTRA_PACKAGES is intentionally not quoted to allow word splitting
# This enables passing multiple package names separated by spaces
# shellcheck disable=SC2086
composer require $COMPOSER_EXTRA_PACKAGES --no-install --no-interaction --no-progress
if [ $? -eq 0 ]; then
echo "Running composer install to install packages without dev dependencies..."
composer install --no-dev --no-interaction --no-progress --optimize-autoloader
if [ $? -eq 0 ]; then
echo "Successfully installed additional composer packages"
else
echo "Failed to install composer dependencies"
exit 1
fi
else
echo "Failed to add additional composer packages to composer.json"
exit 1
fi
fi
if grep -q ^DATABASE_URL= .env; then
echo "Waiting for database to be ready..."
ATTEMPTS_LEFT_TO_REACH_DATABASE=60

View file

@ -39,6 +39,28 @@ if [ -d /var/www/html/var/db ]; then
fi
fi
# Install additional composer packages if COMPOSER_EXTRA_PACKAGES is set
if [ -n "$COMPOSER_EXTRA_PACKAGES" ]; then
echo "Installing additional composer packages: $COMPOSER_EXTRA_PACKAGES"
# Note: COMPOSER_EXTRA_PACKAGES is intentionally not quoted to allow word splitting
# This enables passing multiple package names separated by spaces
# shellcheck disable=SC2086
sudo -E -u www-data composer require $COMPOSER_EXTRA_PACKAGES --no-install --no-interaction --no-progress
if [ $? -eq 0 ]; then
echo "Running composer install to install packages without dev dependencies..."
sudo -E -u www-data composer install --no-dev --no-interaction --no-progress --optimize-autoloader
if [ $? -eq 0 ]; then
echo "Successfully installed additional composer packages"
else
echo "Failed to install composer dependencies"
exit 1
fi
else
echo "Failed to add additional composer packages to composer.json"
exit 1
fi
fi
# Start PHP-FPM (the PHP_VERSION is replaced by the configured version in the Dockerfile)
php-fpmPHP_VERSION -F &