# Render Blueprint for Soul Sync Django API
# https://render.com/docs/blueprint-spec
# Deploy: connect repo → Render creates web service + Postgres and sets DATABASE_URL automatically.

databases:
  - name: soulsync-db
    databaseName: soulsync_db
    user: soulsync
    region: singapore
    plan: free

services:
  - type: web
    name: soul-sync-api
    env: python
    region: singapore

    buildCommand: "./build.sh"
    startCommand: "./start.sh"
    preDeployCommand: python manage.py migrate --no-input

    envVars:
      - key: PYTHON_VERSION
        value: "3.12.0"
      - key: SECRET_KEY
        generateValue: true
      - key: DEBUG
        value: "False"
      # Use your actual Render URL (e.g. soul-sync-service-backend.onrender.com)
      - key: ALLOWED_HOSTS
        value: soul-sync-api.onrender.com
      - key: CORS_ALLOWED_ORIGINS
        value: https://your-frontend-domain.com,http://localhost:3000,http://127.0.0.1:3000
      - key: DATABASE_URL
        fromDatabase:
          name: soulsync-db
          property: connectionString
    healthCheckPath: /admin/
