From 6ea23d16a007f22e38d42cb1506ec8eabdb667cd Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Tue, 6 Feb 2024 02:29:58 +0100 Subject: [PATCH] Tweaked framework initialization --- config/frameworks/00-no-fpm.sh | 9 +++++++++ config/frameworks/10-symfony.sh | 24 +++++++++++++++++++++--- config/frameworks/90-composer.sh | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 config/frameworks/00-no-fpm.sh diff --git a/config/frameworks/00-no-fpm.sh b/config/frameworks/00-no-fpm.sh new file mode 100644 index 0000000..8ca4f79 --- /dev/null +++ b/config/frameworks/00-no-fpm.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -f /application/.no-fpm ]; then + echo " -> Disabling php-fpm service..." + rm -f /etc/supervisor.d/php-fpm.ini +fi + +# scripts at level 00 should not end the framework setup +exit 1 diff --git a/config/frameworks/10-symfony.sh b/config/frameworks/10-symfony.sh index 6cb5986..0f876aa 100644 --- a/config/frameworks/10-symfony.sh +++ b/config/frameworks/10-symfony.sh @@ -1,33 +1,51 @@ #!/bin/sh +# If there is no symfony.lock file, this isn't a symfony project if [ ! -f /application/symfony.lock ]; then exit 1 fi +# Determine if this is a specific variant of Symfny if [ -d /application/config/bolt ]; then - echo " == Detected Symfony (Bolt) project" + echo " => Detected Symfony (Bolt) project" VARIANT=bolt else - echo " == Detected Symfony project" + echo " => Detected Symfony project" VARIANT=vanilla fi +# Call pre-init script if [ -f /application/.symfony-preinit ]; then echo " -> Running container-provided .symfony-preinit script" sh /application/.symfony-preinit fi +# Call on composer echo " -> Installing dependencies using composer..." /usr/bin/composer install --no-dev --no-cache --optimize-autoloader --no-progress -q || exit 0 +# Call post-init script if [ -f /application/.symfony-init ]; then echo " -> Running container-provided .symfony-init script" sh /application/.symfony-init fi +echo " -> Setting up directories..." +test -d /application/var/cache/prod || ( mkdir -p /application/var/cache/prod && chmod a+rwx /application/var/cache/prod ) + +# Do some variant-specific setup +case "$VARIANT" in + "vanilla") + echo " -> Compiling .env for prodution..." + composer symfony:dump-env prod -q + echo " -> Clearing cache..." + bin/console cache:clear --env=prod -q + ;; +esac + echo " -> Testing environment..." if bin/console about -q; then - echo " ++ Successful" + echo " Successful" else echo " !! Failed" fi diff --git a/config/frameworks/90-composer.sh b/config/frameworks/90-composer.sh index ecfab1c..a0b2633 100644 --- a/config/frameworks/90-composer.sh +++ b/config/frameworks/90-composer.sh @@ -4,7 +4,7 @@ if [ ! -f /application/composer.json ]; then exit 1 fi -echo " == Detected composer project." +echo " => Detected composer project." echo " -> Installing dependencies using composer..." /usr/bin/composer install --no-dev --no-cache --optimize-autoloader --no-progress -q || exit 0