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-29 00:34:03 -04:00

37 lines
1.0 KiB
Bash

#!/bin/bash
# Default to sqlite if not specified
DB_TYPE="${DB_TYPE:-sqlite}"
# Wait for PostgreSQL if needed
if [ "$DB_TYPE" = "postgresql" ]; then
MAX_WAIT=180
WAIT_INTERVAL=2
WAITED=0
echo "Database type is PostgreSQL. Waiting for database to be ready..."
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."
else
echo "Database type is SQLite. Skipping PostgreSQL readiness check."
fi
# Apply migrations
echo "Applying database migrations..."
flask db upgrade
# Start periodic image import in background
echo "Starting 2h import loop"
python image_import_worker.py &
# Start the Flask app
echo "Starting Flask app..."
exec flask run --host=0.0.0.0 --port=5000