feat: add support for Doctrine ORM (#74)
* feat: add support for Doctrine ORM * feat: wait for DB and handle migrations if necessary * feat: automatically use the MARIADB password * fix cs * feat: switch to postgres * feat: switch to Postgres
This commit is contained in:
parent
24e5a85265
commit
a6a1f7711e
@ -15,6 +15,8 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
environment:
|
environment:
|
||||||
|
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
|
||||||
|
DATABASE_URL: postgresql://${POSTGRES_USER:-symfony}:${POSTGRES_PASSWORD:-ChangeMe}@db:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-13}
|
||||||
SYMFONY_VERSION:
|
SYMFONY_VERSION:
|
||||||
|
|
||||||
caddy:
|
caddy:
|
||||||
|
@ -29,6 +29,27 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
|
|||||||
composer install --prefer-dist --no-progress --no-suggest --no-interaction
|
composer install --prefer-dist --no-progress --no-suggest --no-interaction
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if grep -q DATABASE_URL= .env; then
|
||||||
|
echo "Waiting for db to be ready..."
|
||||||
|
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
|
||||||
|
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || bin/console doctrine:query:sql "SELECT 1" > /dev/null 2>&1; do
|
||||||
|
sleep 1
|
||||||
|
ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE-1))
|
||||||
|
echo "Still waiting for db to be ready... Or maybe the db is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then
|
||||||
|
echo "The db is not up or not reachable"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "The db is now ready and reachable"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ls -A migrations/*.php > /dev/null 2>&1; then
|
||||||
|
bin/console doctrine:migrations:migrate --no-interaction
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
||||||
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user