services:
  - type: web
    name: automatisch-main
    env: docker
    dockerfilePath: ./docker/Dockerfile
    dockerContext: .
    repo: https://github.com/automatisch/automatisch
    autoDeploy: false
    envVars:
      - key: HOST
        fromService:
          name: automatisch-main
          type: web
          envVarKey: RENDER_EXTERNAL_HOSTNAME
      - key: POSTGRES_HOST
        fromDatabase:
          name: automatisch-database
          property: host
      - key: POSTGRES_PORT
        fromDatabase:
          name: automatisch-database
          property: port
      - key: POSTGRES_DATABASE
        fromDatabase:
          name: automatisch-database
          property: database
      - key: POSTGRES_USERNAME
        fromDatabase:
          name: automatisch-database
          property: user
      - key: POSTGRES_PASSWORD
        fromDatabase:
          name: automatisch-database
          property: password
      - key: REDIS_HOST
        fromService:
          type: redis
          name: automatisch-redis
          property: host
      - key: REDIS_PORT
        fromService:
          type: redis
          name: automatisch-redis
          property: port
      - fromGroup: common-env-vars
  - type: worker
    name: automatisch-worker
    env: docker
    dockerfilePath: ./docker/Dockerfile
    dockerContext: .
    repo: https://github.com/automatisch/automatisch
    autoDeploy: false
    envVars:
      - key: WORKER
        value: true
      - key: HOST
        fromService:
          name: automatisch-main
          type: web
          envVarKey: RENDER_EXTERNAL_HOSTNAME
      - key: POSTGRES_HOST
        fromDatabase:
          name: automatisch-database
          property: host
      - key: POSTGRES_PORT
        fromDatabase:
          name: automatisch-database
          property: port
      - key: POSTGRES_DATABASE
        fromDatabase:
          name: automatisch-database
          property: database
      - key: POSTGRES_USERNAME
        fromDatabase:
          name: automatisch-database
          property: user
      - key: POSTGRES_PASSWORD
        fromDatabase:
          name: automatisch-database
          property: password
      - key: REDIS_HOST
        fromService:
          type: redis
          name: automatisch-redis
          property: host
      - key: REDIS_PORT
        fromService:
          type: redis
          name: automatisch-redis
          property: port
      - fromGroup: common-env-vars
  - type: redis
    name: automatisch-redis
    ipAllowList: [] # allow only internal connections
    maxmemoryPolicy: noeviction
databases:
  - name: automatisch-database
    databaseName: automatisch
envVarGroups:
  - name: common-env-vars
    envVars:
      - key: APP_ENV
        value: production
      - key: PROTOCOL
        value: https
      - key: PORT
        value: 443
      - key: ENCRYPTION_KEY
        generateValue: true
      - key: WEBHOOK_SECRET_KEY
        generateValue: true
      - key: APP_SECRET_KEY
        generateValue: true
