job "${name}" { region = "global" datacenters = ["dc1"] type = "service" group "${name}" { network { mode = "bridge" %{ if service_port != null ~} port "main" { %{ if ingress } host_network = "wesher" %{~ endif } to = ${service_port} } %{ endif } } %{ if length(group_meta) > 0 } meta = { %{ for k, v in group_meta } ${k} = ${jsonencode(v)} %{ endfor } } %{~ endif } %{ if sticky_disk } ephemeral_disk { migrate = true sticky = true } %{~ endif } %{ for host_volume in host_volumes } volume "${host_volume.name}" { type = "host" read_only = ${host_volume.read_only} source = "${host_volume.name}" } %{ endfor } %{ if service_port != null ~} service { name = "${replace(name, "_", "-")}" provider = "nomad" port = "main" tags = [ # TODO: Rename metrics_port_name to something like "prometheus_scrape" %{ if metrics_port_name != null } "prometheus.scrape", %{ endif } %{ if ingress } "traefik.enable=true", "traefik.http.routers.${name}.entryPoints=websecure", %{ if try(ingress_rule, null) != null ~} "traefik.http.routers.${name}.rule=${ingress_rule}", %{ endif ~} %{ for middleware in ingress_middlewares ~} "traefik.http.routers.${name}.middlewares=${middleware}", %{~ endfor } %{~ endif } ] } %{ endif ~} task "${name}" { driver = "docker" %{ if length(meta) > 0 ~} meta = { %{ for k, v in meta ~} ${k} = ${jsonencode(v)} %{ endfor ~} } %{ endif ~} config { image = "${image}" %{if image_pull_timeout != null ~} image_pull_timeout = "${image_pull_timeout}" %{ endif ~} %{ if service_port != null ~} ports = ["main"] %{ endif ~} %{ if length(try(args, [])) > 0 ~} args = ${jsonencode(args)} %{ endif ~} %{ for template in templates ~} %{ if template.mount && !template.env ~} mount { type = "bind" target = "${template.dest}" source = "${template.dest_prefix}/${template.dest}" } %{ endif ~} %{ endfor ~} } %{ if length(env) > 0 ~} env = { %{ for k, v in env ~} "${k}" = "${v}" %{ endfor } } %{ endif ~} %{ for volume in host_volumes ~} volume_mount { volume = "${volume.name}" destination = "${volume.dest}" read_only = ${volume.read_only} } %{ endfor ~} %{ for template in templates ~} template { data = <