#!/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 echo "==> Starting application" exec "$@"