services:
  - type: web
    name: sra-backend
    runtime: python
    rootDir: .
    buildCommand: "pip install -r requirements.txt && python manage.py collectstatic --no-input"
    startCommand: "python manage.py migrate --no-input && daphne -b 0.0.0.0 -p $PORT config.asgi:application"
    envVars:
      - key: DATABASE_URL
        sync: false          # paste your Neon connection string here in the Render dashboard
      - key: SECRET_KEY
        generateValue: true  # Render auto-generates a secure value
      - key: DEBUG
        value: "False"
      - key: ALLOWED_HOSTS
        sync: false          # e.g. sra-backend.onrender.com
      - key: CORS_ALLOWED_ORIGINS
        sync: false          # e.g. https://your-app.vercel.app
      - key: FRONTEND_URL
        sync: false          # e.g. https://your-app.vercel.app
      - key: MEDIA_STORAGE
        value: "cloudinary"  # Render free tier has no persistent disk; use Cloudinary for uploads
      - key: CLOUDINARY_CLOUD_NAME
        sync: false
      - key: CLOUDINARY_API_KEY
        sync: false
      - key: CLOUDINARY_API_SECRET
        sync: false
