aboutsummaryrefslogtreecommitdiff
path: root/app/im/deploy/im.hcl
blob: 68eb9fdfbfcb809820f258928b2412591c103a79 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
job "im" {
  datacenters = ["dc1"]
  type = "service"
  priority = 60

  group "matrix" {
    count = 1

    network {
      port "client_port" { static = 8008 }
      port "federation_port" { static = 8448 }
    }

    task "synapse" {
      driver = "docker"

      config {
        image = "superboum/amd64_synapse:v45"
        network_mode = "host"
        readonly_rootfs = true
        ports = [ "client_port", "federation_port" ]
        command = "python"
        args = [
          "-m", "synapse.app.homeserver",
          "-n",
          "-c", "/etc/matrix-synapse/homeserver.yaml"
        ]
        volumes = [
          "secrets/conf:/etc/matrix-synapse",
          "/mnt/glusterfs/chat/matrix/synapse/media:/var/lib/matrix-synapse/media",
          "/mnt/glusterfs/chat/matrix/synapse/uploads:/var/lib/matrix-synapse/uploads",
          "/tmp/synapse-logs:/var/log/matrix-synapse",
          "/tmp/synapse:/tmp"
        ]
      }
      
      template {
        data = file("../config/synapse/homeserver.yaml")
        destination = "secrets/conf/homeserver.yaml"
      }

      template {
        data = file("../config/easybridge/registration.yaml.tpl")
        destination = "secrets/conf/easybridge_registration.yaml"
      }

      template {
        data = file("../config/synapse/log.yaml")
        destination = "secrets/conf/log.yaml"
      }

      template {
        data = file("../config/synapse/conf.d/server_name.yaml")
        destination = "secrets/conf/server_name.yaml"
      }

      template {
        data = file("../config/synapse/conf.d/report_stats.yaml")
        destination = "secrets/conf/report_stats.yaml"
      }

      # --- secrets ---
      template {
        data = "{{ key \"secrets/chat/synapse/homeserver.tls.crt\" }}"
        destination = "secrets/conf/homeserver.tls.crt"
      }

      template {
        data = "{{ key \"secrets/chat/synapse/homeserver.tls.dh\" }}"
        destination = "secrets/conf/homeserver.tls.dh"
      }

      template {
        data = "{{ key \"secrets/chat/synapse/homeserver.tls.key\" }}"
        destination = "secrets/conf/homeserver.tls.key"
      }

      template {
        data = "{{ key \"secrets/chat/synapse/homeserver.signing.key\" }}"
        destination = "secrets/conf/homeserver.signing.key"
      }

      env {
        SYNAPSE_CACHE_FACTOR = 1
      }

      resources {
        cpu = 1000
        memory = 2000
      }

      service {
        name = "synapse-client"
        port = "client_port"
        address_mode = "host"
        tags = [
          "matrix",
          "traefik.enable=true",
          "traefik.frontend.entryPoints=https",
          "traefik.frontend.rule=Host:im.deuxfleurs.fr;PathPrefix:/_matrix,/_synapse",
          "traefik.frontend.headers.customResponseHeaders=Access-Control-Allow-Origin: *",
          "traefik.frontend.priority=100"
        ]
        check {
          type = "tcp"
          port = "client_port"
          interval = "60s"
          timeout = "5s"
          check_restart {
            limit = 3
            grace = "90s"
            ignore_warnings = false
          }
        }
      }

      service {
        name = "synapse-federation"
        port = "federation_port"
        address_mode = "host"
        tags = [
          "matrix",
          "traefik.enable=true",
          "traefik.frontend.entryPoints=https",
          "traefik.frontend.rule=Host:deuxfleurs.fr;PathPrefix:/_matrix",
          "traefik.frontend.priority=100"
        ]
      }
    }
  }


  group "riotweb" {
    count = 1

    network {
      port "web_port" { to = 8043 }
    }

    task "server" {
      driver = "docker"
      config {
        image = "superboum/amd64_riotweb:v23"
        ports = [ "web_port" ]
        volumes = [
          "secrets/config.json:/srv/http/config.json"
        ]
      }

      template {
        data = file("../config/riot_web/config.json")
        destination   = "secrets/config.json"
      }

      resources {
        memory = 21
      }

      service {
        tags = [
          "webstatic",
          "traefik.enable=true",
          "traefik.frontend.entryPoints=https",
          "traefik.frontend.rule=Host:im.deuxfleurs.fr,riot.deuxfleurs.fr;PathPrefix:/",
          "traefik.frontend.priority=10"
        ]
        port = "web_port"
        address_mode = "host"
        name = "webstatic"
        check {
          type = "tcp"
          port = "web_port"
          interval = "60s"
          timeout = "5s"
          check_restart {
            limit = 3
            grace = "90s"
            ignore_warnings = false
          }
        }
      }
    }
  }
}