Skip to content

Commit 4399616

Browse files
Copilotjbtronics
andcommitted
Add COMPOSER_EXTRA_PACKAGES environment variable support for Docker containers
Co-authored-by: jbtronics <[email protected]>
1 parent 18aa531 commit 4399616

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

.docker/frankenphp/docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
2626
composer install --prefer-dist --no-progress --no-interaction
2727
fi
2828

29+
# Install additional composer packages if COMPOSER_EXTRA_PACKAGES is set
30+
if [ -n "$COMPOSER_EXTRA_PACKAGES" ]; then
31+
echo "Installing additional composer packages: $COMPOSER_EXTRA_PACKAGES"
32+
composer require $COMPOSER_EXTRA_PACKAGES --no-interaction --no-progress --optimize-autoloader
33+
if [ $? -eq 0 ]; then
34+
echo "Successfully installed additional composer packages"
35+
else
36+
echo "Failed to install additional composer packages"
37+
exit 1
38+
fi
39+
fi
40+
2941
if grep -q ^DATABASE_URL= .env; then
3042
echo "Waiting for database to be ready..."
3143
ATTEMPTS_LEFT_TO_REACH_DATABASE=60

.docker/partdb-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ if [ -d /var/www/html/var/db ]; then
3939
fi
4040
fi
4141

42+
# Install additional composer packages if COMPOSER_EXTRA_PACKAGES is set
43+
if [ -n "$COMPOSER_EXTRA_PACKAGES" ]; then
44+
echo "Installing additional composer packages: $COMPOSER_EXTRA_PACKAGES"
45+
sudo -E -u www-data composer require $COMPOSER_EXTRA_PACKAGES --no-interaction --no-progress --optimize-autoloader
46+
if [ $? -eq 0 ]; then
47+
echo "Successfully installed additional composer packages"
48+
else
49+
echo "Failed to install additional composer packages"
50+
exit 1
51+
fi
52+
fi
53+
4254
# Start PHP-FPM (the PHP_VERSION is replaced by the configured version in the Dockerfile)
4355
php-fpmPHP_VERSION -F &
4456

docs/installation/installation_docker.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ services:
8080
#- BANNER=This is a test banner<br>with a line break
8181

8282
# 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):
83-
# - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
83+
# - TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
84+
85+
# If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here:
86+
# The packages will be installed automatically when the container starts
87+
# - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
8488
```
8589

8690
4. Customize the settings by changing the environment variables (or adding new ones). See [Configuration]({% link
@@ -149,6 +153,9 @@ services:
149153
# Override value if you want to show a given text on homepage.
150154
# When this is commented out the webUI can be used to configure the banner
151155
#- BANNER=This is a test banner<br>with a line break
156+
157+
# If you need to install additional composer packages (e.g., for specific mailer transports), you can specify them here:
158+
# - COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
152159

153160
database:
154161
container_name: partdb_database
@@ -169,6 +176,38 @@ services:
169176

170177
```
171178

179+
### Installing additional composer packages
180+
181+
If you need to use specific mailer transports or other functionality that requires additional composer packages, you can
182+
install them automatically at container startup using the `COMPOSER_EXTRA_PACKAGES` environment variable.
183+
184+
For example, if you want to use Mailgun as your email provider, you need to install the `symfony/mailgun-mailer` package.
185+
Add the following to your docker-compose.yaml environment section:
186+
187+
```yaml
188+
environment:
189+
- COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer
190+
- MAILER_DSN=mailgun+api://API_KEY:DOMAIN@default
191+
```
192+
193+
You can specify multiple packages by separating them with spaces:
194+
195+
```yaml
196+
environment:
197+
- COMPOSER_EXTRA_PACKAGES=symfony/mailgun-mailer symfony/sendgrid-mailer
198+
```
199+
200+
{: .info }
201+
> The packages will be installed when the container starts. This may increase the container startup time on the first run.
202+
> The installed packages will persist in the container until it is recreated.
203+
204+
Common mailer packages you might need:
205+
- `symfony/mailgun-mailer` - For Mailgun email service
206+
- `symfony/sendgrid-mailer` - For SendGrid email service
207+
- `symfony/brevo-mailer` - For Brevo (formerly Sendinblue) email service
208+
- `symfony/amazon-mailer` - For Amazon SES email service
209+
- `symfony/postmark-mailer` - For Postmark email service
210+
172211
### Update Part-DB
173212

174213
You can update Part-DB by pulling the latest image and restarting the container.

0 commit comments

Comments
 (0)