# Render Blueprint: TimeTracker Web Service + PostgreSQL
# Uses the pre-built Docker image from GitHub Container Registry (built by cd-release / cd-development).
# No build step: deploy the image that already works in GitHub Actions.

databases:
  - name: timetracker-db
    databaseName: timetracker
    user: timetracker
    plan: free

services:
  - type: web
    name: timetracker
    runtime: image
    region: oregon

    image:
      url: ghcr.io/drytrix/timetracker:latest
      # If the image is private, add registry credentials in Render Dashboard (Settings > Registry)
      # and set: creds: fromRegistryCreds: name: your-ghcr-credential

    # Same as docker-compose: image default CMD runs python /app/start.py (DB wait, migrate, seed, gunicorn). start.py binds to PORT when set.
    healthCheckPath: /_health

    envVars:
      - key: FLASK_ENV
        value: production
      - key: FLASK_APP
        value: app:create_app()
      - key: SECRET_KEY
        generateValue: true
      - key: DATABASE_URL
        fromDatabase:
          name: timetracker-db
          property: connectionString
      - key: AUTH_METHOD
        value: local
      - key: REDIS_ENABLED
        value: "false"
      # Demo mode: uncomment below and set DEMO_PASSWORD in Render Dashboard for a single-user demo
      # - key: DEMO_MODE
      #   value: "true"
      # - key: DEMO_USERNAME
      #   value: demo
      # - key: DEMO_PASSWORD
      #   sync: false
