databases:
  - name: maybe
    user: maybe
    plan: free

services:
  - type: web
    plan: free
    autoDeploy: false
    runtime: ruby
    name: maybe
    repo: https://github.com/maybe-finance/maybe.git
    branch: main
    healthCheckPath: /up
    buildCommand: "./bin/render-build.sh"
    preDeployCommand: "bundle exec rails db:migrate"
    startCommand: "bundle exec rails server"
    envVars:
      - key: DATABASE_URL
        fromDatabase:
          name: maybe
          property: connectionString

      - key: SELF_HOSTED
        value: true
      - key: HOSTING_PLATFORM
        value: render

      # Since the app is self-hosted, we cannot use master.key to encrypt credentials.  App depends entirely on ENV variables
      # https://api.rubyonrails.org/v7.1.3.2/classes/Rails/Application.html#method-i-secret_key_base
      #
      # To generate this, run: `openssl rand -hex 64` or `rails secret`
      - key: SECRET_KEY_BASE
        sync: false

      - key: WEB_CONCURRENCY
        value: 2
      - key: GOOD_JOB_EXECUTION_MODE
        value: async # Typically, `external` is used in prod, but this avoids another cron service and is generally fine for a self-hoster given low traffic

      # The app uses this info to know which repo to fetch latest commit data from for upgrades
      # This should MATCH the `repo` and `branch` keys in the config above ALWAYS
      - key: GITHUB_REPO_OWNER
        value: maybe-finance
      - key: GITHUB_REPO_NAME
        value: maybe
      - key: GITHUB_REPO_BRANCH
        value: main

      # Required to allow your self-hosted instance to be able to upgrade itself
      - key: UPGRADES_ENABLED
        value: true

      # If you upgrade your instance to a paid plan, you can set this to false (or remove it)
      # See note in `render-build.sh` script.
      - key: RUN_DB_MIGRATIONS_IN_BUILD_STEP
        value: true
