entrypoint.sh 715 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. set -e
  3. echo "==> Running migrations..."
  4. python manage.py migrate --noinput
  5. echo "==> Collecting static files..."
  6. python manage.py collectstatic --noinput 2>/dev/null || true
  7. echo "==> Creating default admin user..."
  8. python manage.py shell << EOF
  9. from assetapp.models import User
  10. if not User.objects.filter(username='admin').exists():
  11. User.objects.create_superuser('admin', 'admin@example.com', 'admin123')
  12. print('Admin user created: admin/admin123')
  13. else:
  14. print('Admin user already exists')
  15. EOF
  16. echo "==> Starting server..."
  17. if [ "$1" = "gunicorn" ]; then
  18. exec gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 3
  19. else
  20. exec python manage.py runserver 0.0.0.0:8000
  21. fi