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

  group "ddclient" {

    task "ddclient" {
      driver = "docker"

      config {
        image = "ghcr.io/linuxserver/ddclient:v3.10.0-ls104"

        mount {
          type = "bind"
          source = "secrets/ddclient.conf"
          target = "/config/ddclient.conf"
        }
      }

      template {
        data = <<EOH
{{ with nomadVar "nomad/jobs/ddclient" -}}
daemon=900
ssl=yes
use=web
web=api.myip.com

protocol=cloudflare,
zone={{ .zone }},
ttl=1,
login=token,
password={{ .domain_ddclient }}

{{ .domain }}
{{- end }}
        EOH
        destination = "secrets/ddclient.conf"
        change_mode = "restart"
      }

      resources {
        cpu = 50
        memory = 50
        memory_max = 100
      }
    }
  }
}