tons of stuff but working again
This commit is contained in:
@ -1,30 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Resolve DB host/port from vars or defaults
|
||||
# 1) Wait for MySQL to come up
|
||||
DB_HOST="${DB_HOST:-${MYSQL_HOST:-db}}"
|
||||
DB_PORT="${DB_PORT:-${MYSQL_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"
|
||||
|
||||
# Only the "flask" entrypoint needs uploads + migrations
|
||||
# 2) Ensure the shared upload directory is owned and writable
|
||||
UPLOAD_DIR="/app/${UPLOAD_FOLDER:-data/uploads}"
|
||||
mkdir -p "$UPLOAD_DIR"
|
||||
chown -R appuser:appuser "$UPLOAD_DIR"
|
||||
chmod -R u+rwX,g+rwX,o+rX "$UPLOAD_DIR"
|
||||
echo "⏺️ Ensured upload directory exists and is owned by appuser: $UPLOAD_DIR"
|
||||
|
||||
# 3) If we're launching Flask, run migrations and optional seed
|
||||
if [ "$1" = "flask" ]; then
|
||||
|
||||
# Prepare upload dir (web only) — path comes from .env UPLOAD_FOLDER (e.g. "data/uploads")
|
||||
UPLOAD_DIR="/app/${UPLOAD_FOLDER:-static/uploads}"
|
||||
mkdir -p "$UPLOAD_DIR"
|
||||
echo "⏺️ Ensured upload directory exists: $UPLOAD_DIR"
|
||||
|
||||
# Run DB migrations
|
||||
echo "[🛠️] Applying database migrations"
|
||||
flask db upgrade
|
||||
|
||||
# Ensure any missing tables
|
||||
echo "[🛠️] Ensuring tables exist"
|
||||
echo "[🛠️] Ensuring any missing tables"
|
||||
python <<EOF
|
||||
from app import create_app, db
|
||||
app = create_app()
|
||||
@ -32,14 +30,17 @@ with app.app_context():
|
||||
db.create_all()
|
||||
EOF
|
||||
|
||||
# Optional seeding
|
||||
if [ "${ENABLE_DB_SEEDING,,}" = "true" ] || [ "${ENABLE_DB_SEEDING}" = "1" ]; then
|
||||
echo "[🌱] Seeding Data"
|
||||
echo "[🌱] Seeding data"
|
||||
flask preload-data
|
||||
fi
|
||||
|
||||
echo "[🚀] Starting Flask"
|
||||
echo "[🚀] Ready to start Flask"
|
||||
fi
|
||||
|
||||
# Finally hand off to whatever service was requested (flask or celery)
|
||||
exec "$@"
|
||||
# 4) If we're root, drop to appuser; otherwise just run
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
exec gosu appuser "$@"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user