From 3827944aa5cd50f745a6091813454546a7501559 Mon Sep 17 00:00:00 2001 From: amitrana01 Date: Thu, 11 Sep 2025 18:42:15 +0530 Subject: [PATCH] Add bulletproof startup script to fix django_site migration issues - Create startup.sh with proper step-by-step setup and clear logging - Explicit sites migration before configure_site command - Better error handling with set -e - Clean command structure in docker-compose - This should resolve the 'relation django_site does not exist' error The startup script runs migrations in correct order and provides clear feedback. --- docker-compose.dokploy-simple.yml | 9 ++------- startup.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100755 startup.sh diff --git a/docker-compose.dokploy-simple.yml b/docker-compose.dokploy-simple.yml index d8ad5ef..1c72141 100644 --- a/docker-compose.dokploy-simple.yml +++ b/docker-compose.dokploy-simple.yml @@ -17,6 +17,8 @@ services: - db networks: - dokploy-network + command: > + sh -c "chmod +x /app/startup.sh && /app/startup.sh" db: image: postgres:15-alpine @@ -35,10 +37,3 @@ volumes: networks: dokploy-network: external: true - command: > - sh -c "python manage.py migrate && - python manage.py create_groups && - python manage.py setup_social_apps && - python manage.py configure_site --domain=dt.netcoptech.com --name='Django Template' && - python manage.py collectstatic --noinput && - gunicorn --bind 0.0.0.0:8000 --workers 3 --timeout 120 django_project.wsgi:application" diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..550af8c --- /dev/null +++ b/startup.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +echo "🚀 Starting Django application setup..." + +echo "⏳ Waiting for database..." +sleep 5 + +echo "📦 Running database migrations..." +python manage.py migrate --noinput + +echo "🌐 Ensuring Sites framework is set up..." +python manage.py migrate sites --noinput + +echo "👥 Creating user groups..." +python manage.py create_groups + +echo "🔗 Setting up social applications..." +python manage.py setup_social_apps + +echo "🏠 Configuring site domain..." +python manage.py configure_site --domain=dt.netcoptech.com --name="Django Template" + +echo "📁 Collecting static files..." +python manage.py collectstatic --noinput + +echo "✅ Setup completed successfully!" + +echo "🚀 Starting Gunicorn server..." +exec gunicorn --bind 0.0.0.0:8000 --workers 3 --timeout 120 django_project.wsgi:application