Files
natureinpots_community/entrypoint.sh
2025-05-27 04:23:51 -05:00

32 lines
711 B
Bash

#!/bin/bash
set -e
# Wait for the database service to be ready
DB_HOST=${DB_HOST:-db}
DB_PORT=${DB_PORT:-3306}
echo "[⏳] Waiting for database at $DB_HOST:$DB_PORT..."
until nc -z $DB_HOST $DB_PORT; do
sleep 1
done
echo "[✔] Database is up and reachable"
# Initialize migrations folder if needed
if [ ! -d migrations ]; then
echo "[✔] Initializing migrations directory"
flask db init
fi
echo "[✔] Running migrations"
flask db migrate -m "auto"
flask db upgrade
# Seed database if enabled (accept “1” or “true”)
if [ "$ENABLE_DB_SEEDING" = "true" ] || [ "$ENABLE_DB_SEEDING" = "1" ]; then
echo "[🌱] Seeding Data"
flask preload-data
fi
# Start the main process
exec "$@"