<%
  raise "The BETA_NUMBER environment variable must be given" unless ENV["BETA_NUMBER"]
  @data = {
    "1" => {
      "hosts" => {
        "web" => ["fizzy-beta-app-101.df-iad-int.37signals.com"],
        "jobs" => ["fizzy-beta-jobs-101.df-iad-int.37signals.com"],
        "lb" => "fizzy-beta-lb-101.df-iad-int.37signals.com"
      },
      "dbs" => {
        "solidqueue" => "fizzy-beta-solidqueue-db-101.df-iad-int.37signals.com"
      }
    },
    "2" => {
      "hosts" => {
        "web" => ["fizzy-beta-app-102.df-iad-int.37signals.com"],
        "jobs" => ["fizzy-beta-jobs-102.df-iad-int.37signals.com"],
        "lb" => "fizzy-beta-lb-102.df-iad-int.37signals.com"
      },
      "dbs" => {
        "solidqueue" => "fizzy-beta-solidqueue-db-102.df-iad-int.37signals.com"
      }
    },
    "3" => {
      "hosts" => {
        "web" => ["fizzy-beta-app-103.df-iad-int.37signals.com"],
        "jobs" => ["fizzy-beta-jobs-103.df-iad-int.37signals.com"],
        "lb" => "fizzy-beta-lb-103.df-iad-int.37signals.com"
      },
      "dbs" => {
        "solidqueue" => "fizzy-beta-solidqueue-db-103.df-iad-int.37signals.com"
      }
    },
    "4" => {
      "hosts" => {
        "web" => ["fizzy-beta-app-104.df-iad-int.37signals.com"],
        "jobs" => ["fizzy-beta-jobs-104.df-iad-int.37signals.com"],
        "lb" => "fizzy-beta-lb-104.df-iad-int.37signals.com"
      },
      "dbs" => {
        "solidqueue" => "fizzy-beta-solidqueue-db-104.df-iad-int.37signals.com"
      }
    }
  }
  @beta_number = ENV["BETA_NUMBER"]
  raise "Beta #{@beta_number} doesn't appear to be defined" unless @data[@beta_number]

  @web_hosts = @data[@beta_number]["hosts"]["web"]
  @job_hosts = @data[@beta_number]["hosts"]["jobs"]
  @lb_host = @data[@beta_number]["hosts"]["lb"]
  @solidqueue_db = @data[@beta_number]["dbs"]["solidqueue"]
%>

retain_containers: 1

servers:
  web:
    hosts:
      - <%= @web_hosts[0] %>: df_iad
    labels:
      otel_scrape_enabled: true

  jobs:
    hosts:
      - <%= @job_hosts[0] %>: df_iad
    labels:
      otel_scrape_enabled: true

proxy:
  ssl: false

ssh:
  user: app

env:
  clear:
    APP_FQDN: beta<%= @beta_number %>.fizzy-beta.com
    CACHE_NAMESPACE: <%= @beta_number %>
    RAILS_ENV: beta
    RAILS_LOG_LEVEL: fatal # suppress unstructured log lines
    MYSQL_DATABASE_HOST: fizzy-mysql-primary
    MYSQL_DATABASE_REPLICA_HOST: fizzy-mysql-replica
    MYSQL_SOLID_CABLE_HOST: fizzy-mysql-primary
    MYSQL_SOLID_QUEUE_HOST: <%= @solidqueue_db %>
    MYSQL_SOLID_CACHE_HOST: fizzy-beta-solidcache-db-101.df-iad-int.37signals.com
  secret:
    - RAILS_MASTER_KEY
    - MYSQL_ALTER_PASSWORD
    - MYSQL_ALTER_USER
    - MYSQL_APP_PASSWORD
    - MYSQL_APP_USER
    - MYSQL_READONLY_PASSWORD
    - MYSQL_READONLY_USER
    - SECRET_KEY_BASE
    - VAPID_PUBLIC_KEY
    - VAPID_PRIVATE_KEY
    - ACTIVE_STORAGE_ACCESS_KEY_ID
    - ACTIVE_STORAGE_SECRET_ACCESS_KEY
    - QUEENBEE_API_TOKEN
    - QUEENBEE_SECRET
    - SIGNAL_ID_SECRET
    - SENTRY_DSN
    - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY
    - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY
    - ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT
    - STRIPE_MONTHLY_V1_PRICE_ID
    - STRIPE_MONTHLY_EXTRA_STORAGE_V1_PRICE_ID
    - STRIPE_SECRET_KEY
    - STRIPE_WEBHOOK_SECRET
    - APNS_KEY_ID
    - APNS_ENCRYPTION_KEY_B64
    - FCM_ENCRYPTION_KEY_B64
  tags:
    df_iad:
      PRIMARY_DATACENTER: true

accessories:
  load-balancer:
    image: basecamp/kamal-proxy:lb
    host: <%= @lb_host %>
    labels:
      otel_role: load-balancer
      otel_service: fizzy-load-balancer
      otel_scrape_enabled: true
    options:
      publish:
        - 80:80
        - 443:443
    volumes:
      - load-balancer:/home/kamal-proxy/.config/kamal-proxy
