job "caddy" {
  datacenters = ["dc1"]
  type = "service"

  group "caddy" {
    count = 1

    network {
      port "http" {
        to = 80
      }
    }

    service {
      name = "caddy"
      provider = "consul"
      port = "http"

      tags = [
        "traefik.enable=true", 
        "traefik.http.routers.caddy.tls=true",
        "traefik.http.routers.caddy.entrypoints=websecure",
        "traefik.http.routers.caddy.rule=Host(`example.local`)"
        ]

      check {
        type = "http"
        path = "/"
        interval = "10s"
        timeout = "2s"
      }
    }

    task "caddy" {
      driver = "docker"

      config {
        image = "caddy:alpine"
        ports = ["http"]
      }

    }
  }
}