job "plausible" {
  datacenters = ["alo"]
  meta {
    uuid = uuidv4()
  }

  group "analytics" {
    network {
      port "http" {
        to = 8000
      }
    }

    task "plausible" {
      driver = "docker"

      config {
        image = "plausible/analytics:v2"
        command = "/bin/sh"
        args = ["-c", "sleep 10 && /entrypoint.sh db migrate && /entrypoint.sh run"]
        ports = [ "http" ]
      }

      env {
        DATABASE_URL = "postgres://plausible:jooRichahFoQui9eTo5h@postgres.service.consul:5432/plausible_db?ssl=false"
        CLICKHOUSE_DATABASE_URL = "http://clickhouse.service.consul:8123/plausible_events_db"
        MAILER_EMAIL = "hello@alo.land"
        SMTP_HOST_ADDR = "192.168.1.1"
        ADMIN_USER_EMAIL = "petru@paler.net"
        ADMIN_USER_NAME = "ppetru"
        ADMIN_USER_PWD = "bShs7bqzF8e8jWADGScw"
        BASE_URL = "https://a.alo.land"
        SECRET_KEY_BASE = "K5GOnw7Ozeln/S7wLNbrJw12Dy40kDa2bE2CMKBaGYW/OHdOdSaxj8MrPkvCkULi9"
        GOOGLE_CLIENT_ID = "481110282602-9kjrskre00epg9hig5v2qu98qhvnb5ts.apps.googleusercontent.com"
        GOOGLE_CLIENT_SECRET = "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"
      }

      service {
        name = "plausible"
        port = "http"
        check {
          type = "http"
          port = "http"
          path = "/api/health"
          interval = "30s"
          timeout = "5s"
        }
        tags = [
          "traefik.enable=true",
          "traefik.http.routers.plausible.entryPoints=websecure",
          "traefik.http.routers.plausible.rule=Host(`a.alo.land`)",
        ]
      }

      resources {
        cpu = 1000
        memory = 2000
      }
    }
  }
}
