aboutsummaryrefslogtreecommitdiff
path: root/app/im/deploy/im.hcl
blob: 3cf4e9557fa015438b8b6495244dc5aeba9378f5 (plain) (blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
job "im" {
  datacenters = ["neptune"]
  type = "service"
  
  group "synapse" {
    count = 1

    constraint {
      attribute = "${attr.unique.hostname}"
      operator = "="
      value = "cariacou"
    }

    network {
      port "http" {
        to = 8008
      }
    }

		ephemeral_disk {
			size    = 1000
		}

    task "restore-db" {
      lifecycle {
        hook = "prestart"
        sidecar = false
      }

      driver = "docker"
      config {
        image = "litestream/litestream:0.3.7"
        args = [
		      "restore", "-config", "/etc/litestream.yml", "/ephemeral/homeserver.db"
        ]
				volumes = [
          "../alloc/data:/ephemeral",
					"secrets/litestream.yml:/etc/litestream.yml"
				]
      }

      template {
        data = file("../config/litestream.yml")
        destination = "secrets/litestream.yml"
      }

      resources {
        memory = 1000
        cpu = 1000
      }
    }

    task "synapse" {
      driver = "docker"
      config {
        image = "matrixdotorg/synapse:v1.48.0"
        ports = [ "http" ]

			  entrypoint = [ "/usr/local/bin/python" ]
        args = [
          "-m", "synapse.app.homeserver",
          "-n",
          "-c", "/etc/matrix-synapse/homeserver.yaml"
        ]

        volumes = [
          "secrets:/etc/matrix-synapse",
          "../alloc/data:/ephemeral",
          "/mnt/ssd/synapse:/data",
        ]
      }

      template {
        data = file("../config/homeserver.yaml")
        destination = "secrets/homeserver.yaml"
      }

      template {
        data = "{{ key \"secrets/synapse/signing_key\" }}"
        destination = "secrets/signing_key"
      }

      resources {
        memory = 1500
        cpu = 1000
      }

			restart {
				attempts = 3
				delay    = "30s"
			}

			service {
				port = "http"
				tags = [
					"tricot matrix.home.adnab.me 100",
					"tricot matrix.home.adnab.me:443 100",
					"tricot-add-header Access-Control-Allow-Origin *",
				]
				check {
					type = "http"
					path = "/"
					interval = "10s"
					timeout = "2s"
				}
			}
    }

    task "replicate-db" {
      driver = "docker"
      config {
        image = "litestream/litestream:0.3.7"
        args = [
		      "replicate", "-config", "/etc/litestream.yml"
        ]
				volumes = [
          "../alloc/data:/ephemeral",
					"secrets/litestream.yml:/etc/litestream.yml"
				]
      }

      template {
        data = file("../config/litestream.yml")
        destination = "secrets/litestream.yml"
      }

      resources {
        memory = 500
        cpu = 100
      }
    }
  }
}