Skip to content

Commit c55b04f

Browse files
committed
[deploy] add worker to Terraform Swarm deployment
1 parent 2952655 commit c55b04f

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
resource "docker_service" "worker" {
2+
name = "${var.app-name}-worker"
3+
4+
task_spec {
5+
container_spec {
6+
image = docker_image.app.name
7+
command = ["/app/app", "worker"]
8+
9+
env = jsondecode(base64decode(var.app-env-json-b64))
10+
11+
secrets {
12+
secret_id = docker_secret.config.id
13+
secret_name = docker_secret.config.name
14+
file_name = "/app/config.yml"
15+
file_mode = 384
16+
file_uid = 405
17+
file_gid = 100
18+
}
19+
20+
#region Prometheus support
21+
labels {
22+
label = "prometheus.io/scrape"
23+
value = "true"
24+
}
25+
labels {
26+
label = "prometheus.io/port"
27+
value = "3000"
28+
}
29+
labels {
30+
label = "prometheus.io/job"
31+
value = "worker"
32+
}
33+
#endregion
34+
}
35+
36+
networks_advanced {
37+
name = data.docker_network.internal.id
38+
}
39+
40+
resources {
41+
limits {
42+
memory_bytes = var.memory-limit
43+
}
44+
45+
reservation {
46+
memory_bytes = 32 * 1024 * 1024
47+
}
48+
}
49+
}
50+
51+
#region Prometheus support
52+
labels {
53+
label = "prometheus.io/scrape"
54+
value = "true"
55+
}
56+
labels {
57+
label = "prometheus.io/port"
58+
value = "3000"
59+
}
60+
labels {
61+
label = "prometheus.io/job"
62+
value = "worker"
63+
}
64+
#endregion
65+
66+
rollback_config {
67+
order = "stop-first"
68+
monitor = "5s"
69+
}
70+
71+
update_config {
72+
order = "stop-first"
73+
failure_action = "rollback"
74+
monitor = "5s"
75+
}
76+
}

0 commit comments

Comments
 (0)