diff --git a/init-php.sh b/init-php.sh index 8bc8490..59f138d 100755 --- a/init-php.sh +++ b/init-php.sh @@ -4,6 +4,17 @@ set -e BASE_DIR=storage/app +# If DB_HOST not set, source the env file +[ -z "${DB_HOST}" -a -r .env ] && . .env + +if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then + 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}" +fi + # If FIDO_DIR not set, source the env file [ -z "${FIDO_DIR}" -a -r .env ] && . .env