- Add docker-entrypoint.sh: runs migrations and bootstraps plugins - Add bootstrap-plugins.sh: installs all plugins (disabled by default) - Update Dockerfile to use entrypoint - Plugins can now be enabled via Settings UI after first deployment - Idempotent: safe to run multiple times - Solves issue where imported prod databases had tables but no plugin registry
35 lines
859 B
Bash
35 lines
859 B
Bash
#!/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 "$@"
|