job "pocket-id" {
  datacenters = ["alo"]

  group "app" {
    network {
      port "http" {
        to = 1411
      }
    }

    task "server" {
      driver = "docker"

      config {
        image = "ghcr.io/pocket-id/pocket-id:v1"
        ports = ["http"]
        volumes = [
          "/data/services/pocket-id:/app/data",
        ]
      }

      env {
        APP_URL = "https://pocket-id.v.paler.net"
        TRUST_PROXY = "true"
        MAXMIND_LICENSE_KEY = "${var.maxmind_license_key}"
        PUID = "1000"
        PGID = "1000"
      }

      resources {
        cpu = 500
        memory = 512
      }

      service {
        name = "pocket-id"
        port = "http"

        tags = [
          "traefik.enable=true",
          "traefik.http.routers.pocket-id.entryPoints=websecure",
        ]
      }
    }
  }
}

variable "maxmind_license_key" {
  type = string
  default = "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"
}
