mastodon.nomad (4141B)
1 # https://github.com/mastodon/mastodon/blob/main/docker-compose.yml 2 3 job "mastodon" { 4 datacenters = ["dc1"] 5 6 vault {} 7 8 group "server" { 9 count = 1 10 11 volume "tls" { 12 type = "csi" 13 source = "certbot" 14 access_mode = "multi-node-multi-writer" 15 attachment_mode = "file-system" 16 } 17 volume "mastodon" { 18 type = "csi" 19 source = "mastodon" 20 access_mode = "multi-node-multi-writer" 21 attachment_mode = "file-system" 22 } 23 24 network { 25 port "redis" { 26 to = 6379 27 } 28 port "https" { 29 static = 44393 30 } 31 port "mastodon_web" {} 32 port "mastodon_streaming" { 33 to = 4000 34 } 35 } 36 37 # Prepare database migrations 38 task "db-upgrade" { 39 driver = "podman" 40 41 volume_mount { 42 volume = "mastodon" 43 destination = "/mastodon/public/system" 44 } 45 46 template { 47 destination = "${NOMAD_TASK_DIR}/env.production" 48 data = file("./templates/env.production.tmpl") 49 env = true 50 } 51 52 config { 53 image = "docker.io/tootsuite/mastodon:latest" 54 force_pull = true 55 command = "bundle" 56 args = ["exec", "rake", "db:migrate"] 57 } 58 59 resources { 60 memory = 50 61 memory_max = 256 62 cpu = 200 63 } 64 65 lifecycle { 66 hook = "prestart" 67 sidecar = false 68 } 69 } 70 71 task "nginx" { 72 driver = "podman" 73 74 config { 75 image = "docker.io/library/nginx:stable-alpine" 76 ports = ["https"] 77 volumes = [ 78 # mount the templated config from the task directory to the container 79 "local/mastodon.conf:/etc/nginx/conf.d/mastodon.conf", 80 ] 81 } 82 83 volume_mount { 84 volume = "tls" 85 destination = "/etc/letsencrypt" 86 } 87 88 template { 89 destination = "${NOMAD_TASK_DIR}/mastodon.conf" 90 data = file("./templates/nginx.conf.tmpl") 91 } 92 93 resources { 94 memory = 50 95 memory_max = 256 96 cpu = 200 97 } 98 } 99 100 task "mastodon-web" { 101 driver = "podman" 102 103 config { 104 image = "docker.io/tootsuite/mastodon:latest" 105 force_pull = true 106 ports = ["mastodon_web"] 107 command = "bash" 108 args = ["-c", "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p ${NOMAD_PORT_mastodon_web}"] 109 } 110 111 volume_mount { 112 volume = "mastodon" 113 destination = "/mastodon/public/system" 114 } 115 116 template { 117 destination = "${NOMAD_TASK_DIR}/env.production" 118 data = file("./templates/env.production.tmpl") 119 env = true 120 } 121 122 resources { 123 memory = 50 124 memory_max = 512 125 cpu = 300 126 } 127 } 128 129 task "mastodon-streaming" { 130 driver = "podman" 131 132 config { 133 image = "ghcr.io/mastodon/mastodon-streaming:latest" 134 force_pull = true 135 ports = ["mastodon_streaming"] 136 command = "node" 137 args = ["./streaming"] 138 } 139 140 template { 141 destination = "${NOMAD_TASK_DIR}/env.production" 142 data = file("./templates/env.production.tmpl") 143 env = true 144 } 145 146 resources { 147 memory = 50 148 memory_max = 300 149 cpu = 200 150 } 151 } 152 153 task "mastodon-sidekiq" { 154 driver = "podman" 155 156 config { 157 image = "docker.io/tootsuite/mastodon:latest" 158 force_pull = true 159 command = "bundle" 160 args = ["exec", "sidekiq"] 161 } 162 163 volume_mount { 164 volume = "mastodon" 165 destination = "/mastodon/public/system" 166 } 167 168 template { 169 destination = "${NOMAD_TASK_DIR}/env.production" 170 data = file("./templates/env.production.tmpl") 171 env = true 172 } 173 174 resources { 175 memory = 50 176 memory_max = 500 177 cpu = 200 178 } 179 } 180 181 task "redis" { 182 driver = "podman" 183 184 config { 185 image = "docker.io/library/redis:7-alpine" 186 ports = ["redis"] 187 } 188 189 resources { 190 memory = 32 191 memory_max = 128 192 cpu = 100 193 } 194 195 lifecycle { 196 hook = "prestart" 197 sidecar = true 198 } 199 } 200 201 } 202 }