21 lines
655 B
Bash
Executable File
21 lines
655 B
Bash
Executable File
#!/bin/sh
|
|
# Container entrypoint: bring the schema up to date, then hand over to the server.
|
|
# Migrations are idempotent, so restarting the container is always safe. Data import
|
|
# scripts (which replace table contents) are never run from here.
|
|
set -eu
|
|
|
|
if [ "${RUN_MIGRATIONS:-1}" = "1" ]; then
|
|
attempt=1
|
|
until alembic upgrade head; do
|
|
if [ "$attempt" -ge 15 ]; then
|
|
echo "entrypoint: database migration failed after $attempt attempts" >&2
|
|
exit 1
|
|
fi
|
|
echo "entrypoint: database not ready (attempt $attempt), retrying in 3s" >&2
|
|
attempt=$((attempt + 1))
|
|
sleep 3
|
|
done
|
|
fi
|
|
|
|
exec "$@"
|