-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.tf
84 lines (74 loc) · 2.2 KB
/
app.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
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
resource "docker_image" "galaxy_app" {
name = "${local.galaxy_app_image}:${var.image_tag}"
}
resource "docker_container" "galaxy_app" {
depends_on = [docker_container.upgrade_db, docker_container.visualizations-fix] # TODO remove '-fix' after https://github.com/galaxyproject/galaxy/issues/11057
name = "${local.app_name}${local.name_suffix}"
image = docker_image.galaxy_app.latest
hostname = local.app_name
domainname = local.app_name
restart = "unless-stopped"
must_run = true
user = "${local.uwsgi_user}:${local.uwsgi_group}"
networks_advanced {
name = local.network
aliases = [local.app_name]
}
env = compact(concat(
[for k, v in local.galaxy_conf : "GALAXY_CONFIG_OVERRIDE_${k}=${v}"],
[for k, v in local.job_conf : "${k}=${v}"],
))
healthcheck {
test = ["CMD", "uwping", "uwsgi://localhost:${local.uwsgi_port}/api/version"]
start_period = "2s"
timeout = "2s"
interval = "10s"
retries = 3
}
dynamic "upload" {
for_each = local.configs
content {
file = "${local.config_dir}/${upload.key}"
content = upload.value
}
}
dynamic "upload" {
for_each = local.macros
content {
file = "${local.config_dir}/macros/${upload.key}"
content = upload.value
}
}
mounts {
source = docker_volume.user_data.name
target = local.data_dir
type = "volume"
read_only = false
}
mounts {
source = docker_volume.galaxy_root.name
target = local.root_dir
type = "volume"
read_only = false
}
dynamic "mounts" {
for_each = var.extra_mounts
content {
source = mounts.value.source
target = mounts.value.target
type = mounts.value.type
read_only = mounts.value.read_only
}
}
}
resource "docker_container" "wait_for_app" {
depends_on = [docker_container.galaxy_app]
image = docker_image.galaxy_app.latest
name = "wait_for_galaxy_app${local.name_suffix}"
must_run = false
attach = true
command = ["bash", "-c", "until uwping uwsgi://${local.app_name}:${local.uwsgi_port}/api/version; do sleep 1; done"]
networks_advanced {
name = local.network
}
}