diff --git a/init-php.sh b/init-php.sh index 43b12e5..c0a48c4 100755 --- a/init-php.sh +++ b/init-php.sh @@ -1,6 +1,16 @@ -#!/bin/sh +#!/bin/bash # Run our web init startup /sbin/init php-fpm & +# Wait for DB to start +# If DB_HOST not set, source the env file +[ -z "${DB_HOST}" -a -r .env ] && . .env + +while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do + echo "? Waiting for database at ${DB_HOST}:${DB_PORT}" + sleep 1; + done +echo "- DB is active on ${DB_HOST}:${DB_PORT}" + exec ./artisan server:start