#!/bin/bash # Docker container entrypoint for ShopDB Flask. # Waits for the database to answer, then starts whatever it was given. # # This deliberately does NOT run migrations, plugin bootstrap or seeds. That # sequence lives in the `migrate` service in docker-compose.yml (and its # equivalents in the pull/airgap compose files) so there is exactly one place # it happens. Running it here as well would mean every api restart re-attempted # schema work, and a failing migration under `restart: unless-stopped` would # crash-loop and bury the original error under retry noise. # # `up -d api` is still safe on its own: compose honours the # service_completed_successfully dependency even when a single service is # named, so the migrate service runs to completion first. set -e echo "==> ShopDB Flask Container Starting" # Wait for database to be ready. Kept here because it is about this container's # own readiness to serve, not about schema state. `flask db current` is a cheap # round-trip that proves the connection works. 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 echo "==> Starting application" exec "$@"