mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-17 15:49:34 +00:00
Add COMPOSER_EXTRA_PACKAGES environment variable support for Docker containers
Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
This commit is contained in:
parent
18aa531c75
commit
43996160c0
3 changed files with 64 additions and 1 deletions
|
|
@ -26,6 +26,18 @@ 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"
|
||||
composer require $COMPOSER_EXTRA_PACKAGES --no-interaction --no-progress --optimize-autoloader
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully installed additional composer packages"
|
||||
else
|
||||
echo "Failed to install additional composer packages"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep -q ^DATABASE_URL= .env; then
|
||||
echo "Waiting for database to be ready..."
|
||||
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ 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"
|
||||
sudo -E -u www-data composer require $COMPOSER_EXTRA_PACKAGES --no-interaction --no-progress --optimize-autoloader
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully installed additional composer packages"
|
||||
else
|
||||
echo "Failed to install additional composer packages"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start PHP-FPM (the PHP_VERSION is replaced by the configured version in the Dockerfile)
|
||||
php-fpmPHP_VERSION -F &
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,11 @@ services:
|
|||
#- BANNER=This is a test banner<br>with a line break
|
||||
|
||||
# If you use a reverse proxy in front of Part-DB, you must configure the trusted proxies IP addresses here (see reverse proxy documentation for more information):
|
||||
# - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
|
||||
# - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
|
||||
|
||||
# If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here:
|
||||
# The packages will be installed automatically when the container starts
|
||||
# - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
|
||||
```
|
||||
|
||||
4. Customize the settings by changing the environment variables (or adding new ones). See [Configuration]({% link
|
||||
|
|
@ -149,6 +153,9 @@ services:
|
|||
# Override value if you want to show a given text on homepage.
|
||||
# When this is commented out the webUI can be used to configure the banner
|
||||
#- BANNER=This is a test banner<br>with a line break
|
||||
|
||||
# If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here:
|
||||
# - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
|
||||
|
||||
database:
|
||||
container_name: partdb_database
|
||||
|
|
@ -169,6 +176,38 @@ services:
|
|||
|
||||
```
|
||||
|
||||
### Installing additional composer packages
|
||||
|
||||
If you need to use specific mailer transports or other functionality that requires additional composer packages, you can
|
||||
install them automatically at container startup using the `COMPOSER_EXTRA_PACKAGES` environment variable.
|
||||
|
||||
For example, if you want to use Mailgun as your email provider, you need to install the `symfony/mailgun-mailer` package.
|
||||
Add the following to your docker-compose.yaml environment section:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer
|
||||
- MAILER_DSN=mailgun+api://API_KEY:DOMAIN@default
|
||||
```
|
||||
|
||||
You can specify multiple packages by separating them with spaces:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
|
||||
```
|
||||
|
||||
{: .info }
|
||||
> The packages will be installed when the container starts. This may increase the container startup time on the first run.
|
||||
> The installed packages will persist in the container until it is recreated.
|
||||
|
||||
Common mailer packages you might need:
|
||||
- `symfony/mailgun-mailer` - For Mailgun email service
|
||||
- `symfony/sendgrid-mailer` - For SendGrid email service
|
||||
- `symfony/brevo-mailer` - For Brevo (formerly Sendinblue) email service
|
||||
- `symfony/amazon-mailer` - For Amazon SES email service
|
||||
- `symfony/postmark-mailer` - For Postmark email service
|
||||
|
||||
### Update Part-DB
|
||||
|
||||
You can update Part-DB by pulling the latest image and restarting the container.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue