clrghouz/init-php.sh
2021-06-26 10:57:18 +10:00

24 lines
631 B
Bash
Executable File

#!/bin/bash
# Run our web init startup
rm -f bootstrap/cache/*.php
/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 15 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
# Wait for our config to have been rebuild
while [ ! -e bootstrap/cache/config.php -o -e .migrate ]; do
echo "? Waiting for configuration to be built by init"
sleep 15;
done
echo "* Ready to start server"
exec su www-data -s /bin/sh -c "./artisan server:start"