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
GallerySubscriber/docker-entrypoint.sh
T
2026-01-25 18:47:06 -05:00

42 lines
1.3 KiB
Bash

#!/bin/bash
set -e
# Fix ownership of data directories (needed for bind mounts)
# Only fix top-level dirs to avoid slow recursive chown on large downloads
echo "Fixing data directory permissions..."
chown appuser:appuser /data /data/downloads /data/config /data/cookies 2>/dev/null || true
# Wait for database to be ready
echo "Waiting for database..."
until gosu appuser python -c "
import asyncio
from sqlalchemy.ext.asyncio import create_async_engine
from app.config import get_settings
async def check():
settings = get_settings()
engine = create_async_engine(settings.async_database_url)
async with engine.connect() as conn:
await conn.execute(__import__('sqlalchemy').text('SELECT 1'))
await engine.dispose()
asyncio.run(check())
" 2>/dev/null; do
echo "Database not ready, waiting..."
sleep 2
done
echo "Database is ready!"
# Only run migrations from the app container (not celery worker)
# This prevents race conditions when multiple containers start simultaneously
if [[ "$1" == "hypercorn" ]]; then
echo "Running database migrations..."
gosu appuser alembic upgrade head
echo "Migrations complete!"
else
echo "Skipping migrations (will be run by app container)"
fi
# Start the application as non-root user
exec gosu appuser "$@"