-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.nomad
88 lines (73 loc) · 1.81 KB
/
deploy.nomad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
variable "image_tag" {
type = string
default = "latest"
}
job "hello-world" {
datacenters = ["main"]
type = "service"
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "30s"
progress_deadline = "2m"
health_check = "checks"
auto_revert = true
}
group "application" {
count = 1
network {
port "http" {
host_network = "private"
}
}
task "server" {
driver = "docker"
config {
image = "docker.your-domain.tld/hello-world:${var.image_tag}"
network_mode = "host"
}
resources {
cpu = 100
memory = 16
}
env {
SERVER_HOST_IP = "${NOMAD_IP_http}"
SERVER_PORT = "${NOMAD_PORT_http}"
}
service {
provider = "nomad"
name = "hello-world"
port = "http"
address_mode = "host"
tags = [
"traefik.enable=true",
"traefik.http.routers.hello-world.rule=Host(`hello.your-domain.tld`)",
"traefik.http.routers.hello-world.tls=true",
"traefik.http.routers.hello-world.tls.certresolver=letsencrypt",
"traefik.http.routers.hello-world.middlewares=response-compress@file",
]
check {
type = "http"
address_mode = "host"
port = "http"
path = "/"
interval = "10s"
timeout = "1s"
check_restart {
limit = 2
grace = "10s"
}
}
}
template {
data = <<-EOF
{{with nomadVar "nomad/jobs/hello-world"}}
MESSAGE="{{.message}}"
{{end}}
EOF
destination = "secrets/vars.env"
env = true
}
}
}
}