diff --git a/entrypoint.sh b/entrypoint.sh index 6827d82..0172f0f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ cp -r storage.skel/* storage/ php /wait-for-db.php -if [[ ! -e storage/.docker.init ]]; +if [[ ! -e storage/.docker.init ]] then echo "Fresh installation, initializing database..." php artisan key:generate @@ -21,5 +21,14 @@ php artisan route:cache php artisan view:cache php artisan config:cache +echo "++++ Check for needed migrations... ++++" +# check for migrations +php artisan migrate:status | grep No && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + php artisan migrate --force +fi + +echo "++++ Start apache... ++++" source /etc/apache2/envvars /usr/local/sbin/dumb-init apache2 -DFOREGROUND diff --git a/worker-entrypoint.sh b/worker-entrypoint.sh index a07ad0a..4fe941b 100755 --- a/worker-entrypoint.sh +++ b/worker-entrypoint.sh @@ -10,4 +10,12 @@ then exit 1 fi +gosu www-data php artisan migrate:status | grep No && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + echo "Database needs migrations, exiting..." + sleep 5 + exit 1 +fi + gosu www-data php artisan horizon