Files
investbrain/docker/entrypoint.sh
T

90 lines
2.4 KiB
Bash
Raw Normal View History

2024-09-04 17:48:40 -05:00
#!/bin/bash
cd /var/app
2024-09-05 21:34:09 -05:00
# Starting Investbrain
2025-07-11 21:43:36 -05:00
echo "CuKWhOKWliAgICAgICAg4paXIOKWjCAgICAg4paYICAK4paQIOKWm+KWjOKWjOKWjOKWiOKWjOKWm+KWmOKWnOKWmOKWm+KWjOKWm+KWmOKWgOKWjOKWjOKWm+KWjArilp/ilpbilozilozilprilpjilpnilpbiloTilozilpDilpbilpnilozilowg4paI4paM4paM4paM4paMCg==" | base64 -d
2025-07-16 17:07:25 -05:00
printf "%15s$VERSION\n"
2025-01-25 22:54:10 -06:00
echo -e "\n====================== Validating environment... ====================== "
# Ensure app storage directory is scaffolded
mkdir -p storage/framework/cache \
storage/framework/sessions \
storage/framework/views \
storage/app \
storage/logs
echo -e "\n > Storage directory scaffolding is OK... "
# Ensure storage directory is permissioned for www-data
chmod -R 775 storage
chown -R www-data:www-data storage
echo -e "\n > Permissions are OK... "
# Ensure app key exists / generate if required
KEY_FILE="storage/app/.key"
if [ -z "$APP_KEY" ] && [ ! -s "$KEY_FILE" ]; then
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-26 21:56:41 -06:00
echo -e "\n\n$border"
2025-01-25 22:19:54 -06:00
echo "* $text *"
2025-01-26 21:45:38 -06:00
echo "$border"
2025-01-25 22:19:54 -06:00
}
export APP_KEY="$(php artisan key:generate --show)"
echo -e "\n > Oops! The required APP_KEY configuration is missing! Generated app key and saved in $KEY_FILE"
echo "$APP_KEY" > "$KEY_FILE"
2025-01-26 11:20:52 -06:00
draw_box $APP_KEY
else
echo -e "\n > APP_KEY is OK... "
2024-09-05 21:49:06 -05:00
fi
2025-01-25 21:53:55 -06:00
echo -e "\n====================== Running migrations... ====================== "
# Wait 60 seconds for database to be ready
RETRIES=12
DELAY=5
2024-12-16 21:54:59 -06:00
run_migrations() {
sleep $DELAY
output=$(php artisan migrate --force 2>/dev/null)
if [[ $? -eq 0 ]]; then
echo "$output"
return 0
else
return 1
fi
2024-12-16 21:54:59 -06:00
}
until run_migrations; do
2025-01-26 21:33:49 -06:00
RETRIES=$((RETRIES-1))
if [[ $RETRIES -le 0 ]]; then
echo -e "\n > Database is not ready after one minute. Exiting... \n"
2025-01-26 21:33:49 -06:00
exit 1
2024-12-16 21:54:59 -06:00
fi
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. \n"
2024-12-16 21:54:59 -06:00
done
2024-09-04 17:48:40 -05:00
2025-07-11 21:33:58 -05:00
echo -e "\n====================== Cleaning up... ====================== \n"
2025-07-11 21:42:11 -05:00
# Clear caches
2025-07-11 21:33:58 -05:00
echo $(php artisan cache:clear)
2025-07-11 21:42:11 -05:00
echo $(php artisan view:clear)
echo $(php artisan route:clear)
echo $(php artisan event:clear)
# Re-create caches
echo $(php artisan route:cache)
echo $(php artisan event:cache)
2025-07-11 21:33:58 -05:00
2025-01-26 21:46:59 -06:00
echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n"
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf