Files
docupulse/entrypoint.sh
2025-05-26 16:13:44 +02:00

41 lines
1.1 KiB
Bash

#!/bin/bash
# Wait for the database to be ready
echo "Waiting for database to be ready..."
while ! nc -z db 5432; do
sleep 0.1
done
echo "Database is ready!"
# Wait for PostgreSQL to be ready to accept connections
echo "Waiting for PostgreSQL to accept connections..."
until PGPASSWORD=$POSTGRES_PASSWORD psql -h db -U $POSTGRES_USER -d $POSTGRES_DB -c '\q'; do
echo "PostgreSQL is unavailable - sleeping"
sleep 1
done
echo "PostgreSQL is up - executing command"
# Remove existing migrations and create fresh ones
echo "Setting up fresh database migrations..."
rm -rf migrations
flask db init
flask db migrate -m "Initial migration"
flask db upgrade
# Create default site settings if they don't exist
echo "Creating default site settings..."
python3 -c "
from app import create_app
from models import SiteSettings, db
app = create_app()
with app.app_context():
try:
settings = SiteSettings.get_settings()
print('Default site settings created successfully')
except Exception as e:
print(f'Error creating site settings: {e}')
"
# Start the application
echo "Starting application..."
exec gunicorn --bind 0.0.0.0:5000 app:app