Files
investbrain/docker/entrypoint.sh
T

43 lines
1.2 KiB
Bash
Raw Normal View History

2024-09-04 17:48:40 -05:00
#!/bin/bash
2024-09-05 21:34:09 -05:00
cd /var/www/app
echo -e "\n====================== Running entrypoint script... ====================== "
2024-09-05 21:34:09 -05:00
if [ ! -f ".env" ]; then
2024-09-04 18:41:04 -05:00
echo " > Ope, gotta create an .env file!"
2024-09-04 17:48:40 -05:00
2024-09-05 21:34:09 -05:00
cp .env.example .env
2024-09-04 17:48:40 -05:00
fi
echo -e "\n====================== Validating environment... ====================== "
2024-09-05 21:49:06 -05:00
if ( ! grep -q "^APP_KEY=" ".env" || grep -q "^APP_KEY=$" ".env"); then
echo " > Ah, APP_KEY is missing in .env file. Generating a new key!"
/usr/local/bin/php artisan key:generate --force
fi
2024-09-09 17:21:08 -05:00
if [ ! -L "public/storage" ]; then
echo " > Creating symbolic link for app public storage..."
/usr/local/bin/php artisan storage:link
fi
echo -e "\n====================== Running migrations... ====================== "
2024-12-16 21:54:59 -06:00
run_migrations() {
/usr/local/bin/php artisan migrate --force
}
RETRIES=30
DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
echo " > Database is not ready after multiple attempts. Exiting..."
2024-12-16 21:54:59 -06:00
exit 1
fi
echo " > Waiting for database to be ready... retrying in $DELAY seconds."
2024-12-16 21:54:59 -06:00
sleep $DELAY
done
2024-09-04 17:48:40 -05:00
echo -e "\n====================== Spinning up Supervisor daemon... ====================== "
2024-09-04 17:48:40 -05:00
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf