-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.tf
54 lines (45 loc) · 1.15 KB
/
docker.tf
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
variable "docker_ca_material" {
type = string
}
variable "docker_cert_material" {
type = string
}
variable "docker_key_material" {
type = string
}
locals {
docker_connection_options = {
host = "tcp://${local.docker_host}:2376/"
ca_material = base64decode(var.docker_ca_material)
cert_material = base64decode(var.docker_cert_material)
key_material = base64decode(var.docker_key_material)
}
}
provider "docker" {
host = local.docker_connection_options.host
ca_material = local.docker_connection_options.ca_material
cert_material = local.docker_connection_options.cert_material
key_material = local.docker_connection_options.key_material
}
resource "docker_service" "cron-manager" {
name = "cron-manager"
task_spec {
container_spec {
image = "crazymax/swarm-cronjob:latest"
env = {
TZ = "US/Eastern"
}
mounts {
target = "/var/run/docker.sock"
source = "/var/run/docker.sock"
type = "bind"
}
}
placement {
constraints = ["node.role==manager"]
}
}
}
output "docker_connection_options" {
value = local.docker_connection_options
}