Files
investbrain/docker/entrypoint.sh
T

55 lines
1.6 KiB
Bash
Raw Permalink 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====================== Installing Composer dependencies... ====================== "
/usr/local/bin/composer install
echo -e "\n====================== Validating environment... ====================== "
2024-09-09 14:49:34 -05:00
if [ $(stat -c '%U' .) != "www-data" ]; then
echo " > Setting correct permissions for pwd..."
chown -R www-data:www-data .
2024-09-08 21:36:37 -05:00
fi
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====================== Installing NPM dependencies and building frontend... ====================== "
/usr/bin/npm install
/usr/bin/npm run build
2024-09-04 17:48:40 -05:00
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