This repository has been archived on 2026-05-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
imagerepo/entrypoint.sh
T
2025-07-28 21:57:49 +00:00

22 lines
644 B
Bash

#!/bin/bash
# Wait for the database to be ready (timeout after 3 minutes)
MAX_WAIT=180 # seconds
WAIT_INTERVAL=2
WAITED=0
until pg_isready -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" > /dev/null 2>&1; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Timeout: Could not connect to the database at $DB_HOST:$DB_PORT within $MAX_WAIT seconds."
exit 1
fi
echo "Waiting for database at $DB_HOST:$DB_PORT... ($WAITED/$MAX_WAIT seconds)"
sleep $WAIT_INTERVAL
WAITED=$((WAITED + WAIT_INTERVAL))
done
echo "Database is ready. Applying migrations..."
flask db upgrade
echo "Starting Flask app..."
exec flask run --host=0.0.0.0 --port=5000