Files
investbrain/docker/entrypoint.sh
T

52 lines
1.4 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
2025-01-25 21:53:55 -06:00
echo -e "\n====================== Validating environment... ====================== "
2025-01-25 22:08:07 -06:00
run_as_www_user() {
su - www-data -c "/usr/local/bin/php /var/www/app/artisan $1"
}
2025-01-25 21:34:18 -06:00
2025-01-25 22:33:27 -06:00
if [[ -z "$APP_KEY" ]]; then
2025-01-25 22:36:48 -06:00
echo " > The required APP_KEY configuration is missing in your .env file. "
echo " > Copy and paste this key into your .env file. Then restart the container! "
2025-01-25 22:19:54 -06:00
draw_box() {
local text="$1"
local length=${#text}
local border=$(printf '%*s' "$((length + 4))" | tr ' ' '*')
2025-01-25 22:36:48 -06:00
echo "$border"
2025-01-25 22:19:54 -06:00
echo "* $text *"
2025-01-25 22:36:48 -06:00
echo "$border"
2025-01-25 22:19:54 -06:00
}
draw_box "base64:$(openssl rand -base64 32)"
2025-01-25 22:22:42 -06:00
exit 1;
2024-09-05 21:49:06 -05:00
fi
2025-01-25 21:53:55 -06:00
if [ ! -L "public/storage" ]; then
echo " > Creating symbolic link for app public storage..."
2024-09-09 17:21:08 -05:00
2025-01-25 22:08:07 -06:00
run_as_www_user "storage:link"
2024-09-09 17:21:08 -05:00
fi
2025-01-25 21:53:55 -06:00
echo -e "\n====================== Running migrations... ====================== "
2024-12-16 21:54:59 -06:00
run_migrations() {
2025-01-25 22:08:07 -06:00
run_as_www_user "migrate --force"
2024-12-16 21:54:59 -06:00
}
RETRIES=30
DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
2025-01-25 21:53:55 -06:00
echo " > Database is not ready after multiple attempts. Exiting..."
2024-12-16 21:54:59 -06:00
exit 1
fi
2025-01-25 21:53:55 -06:00
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
2025-01-25 21:53:55 -06:00
echo -e "\n====================== Spinning up Supervisor daemon... ====================== "
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf