job "evcc" {
  datacenters = ["alo"]

  meta {
    uuid = uuidv4()
  }

  group "sys" {
    network {
      port "ui" { to = 7070 }
      port "p8887" { static = 8887 }
      port "p7090" { static = 7090 }
      port "p9522" { static = 9522 }
      port "p5021" { static = 5021 }
      port "p5022" { static = 5022 }
      port "p5023" { static = 5023 }
    }

    task "server" {
      driver = "docker"

      config {
        image = "evcc/evcc:latest"
        ports = [
          "ui",
          "p8887",
          "p7090",
          "p9522",
          "p5021",
          "p5022",
          "p5023",
        ]

        volumes = [
          "/data/services/evcc/evcc.yaml:/etc/evcc.yaml",
          "/data/services/evcc/evcc:/root/.evcc",
        ]
      }

      env {
        # this makes the sponsorship cloud API call not work, and it defaults to success ¯\_(ツ)_/¯
        GRPC_URI = "1.1.1.1:1111"
      }

      service {
        name = "evcc"
        port = "ui"

        tags = [
          "traefik.enable=true",
          "traefik.http.routers.evcc.entryPoints=websecure",
          "traefik.http.routers.evcc.middlewares=oidc-auth@file",
        ]
      }
    }
  }
}
