#!/bin/bash # Docker container entrypoint for ShopDB Flask. # Runs migrations, bootstraps plugins on first deployment, then starts the app. set -e echo "==> ShopDB Flask Container Starting" # Wait for database to be ready (optional, useful with docker-compose) if [ -n "$DATABASE_URL" ]; then echo "==> Waiting for database..." for i in {1..30}; do if flask db current &>/dev/null; then echo "==> Database ready" break fi echo " Attempt $i/30: database not ready, waiting..." sleep 2 done fi # Run migrations echo "==> Running database migrations" flask db upgrade || { echo "ERROR: Database migrations failed" exit 1 } # Bootstrap plugins on first deployment echo "==> Checking plugin installation" /app/scripts/bootstrap-plugins.sh # Run plugin migrations after bootstrap (creates tables for enabled plugins) # Safe to run even if no plugins are enabled - it will just do nothing echo "==> Running plugin migrations" flask plugin upgrade-all || { echo "WARNING: Plugin migrations failed - some features may not work" } echo "==> Starting application" exec "$@"