a ton of fun happened, refactored alot

This commit is contained in:
2025-07-03 04:29:43 -05:00
parent 72e060d783
commit 1bbe6e2743
121 changed files with 2315 additions and 900 deletions

View File

@ -1,49 +1,46 @@
#!/usr/bin/env bash
set -e
UPLOAD_DIR="/app/static/uploads"
mkdir -p "$UPLOAD_DIR"
chown -R 1000:998 "$UPLOAD_DIR"
chmod -R 775 "$UPLOAD_DIR"
# Resolve DB host/port from vars or defaults
DB_HOST="${DB_HOST:-${MYSQL_HOST:-db}}"
DB_PORT="${DB_PORT:-${MYSQL_PORT:-3306}}"
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"
# Initialize Alembic if not present
if [ ! -d "./migrations" ]; then
echo "[🆕] No migrations directory found; initializing Alembic"
flask db init
echo "[🆕] Generating initial migration"
flask db migrate -m "initial" || echo "[] Nothing to migrate"
fi
# Only the "flask" entrypoint needs uploads + migrations
if [ "$1" = "flask" ]; then
# Autogenerate new migration if needed
echo "[🛠️] Checking for new schema changes"
flask db migrate -m "auto-migrate" || echo "[] No schema changes detected"
# Prepare upload dir (web only)
UPLOAD_DIR="/app/${UPLOAD_FOLDER:-static/uploads}"
mkdir -p "$UPLOAD_DIR"
chown -R 1000:998 "$UPLOAD_DIR"
chmod -R 775 "$UPLOAD_DIR"
# Apply migrations
echo "[] Applying database migrations"
flask db upgrade
# Run DB migrations
echo "[🛠] Applying database migrations"
flask db upgrade
# Create any missing tables (edge case fallback)
echo "[🔧] Running db.create_all() to ensure full sync"
python <<EOF
# Ensure any missing tables
echo "[🛠️] Ensuring tables exist"
python <<EOF
from app import create_app, db
app = create_app()
with app.app_context():
db.create_all()
EOF
# Optional seeding
if [ "$ENABLE_DB_SEEDING" = "true" ] || [ "$ENABLE_DB_SEEDING" = "1" ]; then
echo "[🌱] Seeding Data"
flask preload-data
# Optional seeding
if [ "${ENABLE_DB_SEEDING,,}" = "true" ] || [ "${ENABLE_DB_SEEDING}" = "1" ]; then
echo "[🌱] Seeding Data"
flask preload-data
fi
echo "[🚀] Starting Flask"
fi
echo "[🚀] Starting Flask"
# Finally hand off to whatever service was requested (flask or celery)
exec "$@"