Mastodon: Initial Configuration

This is missing some secrets, will commit those later
This commit is contained in:
Nemo 2022-12-26 12:47:30 +05:30
parent da4fc888ef
commit 587b6258bb
6 changed files with 135 additions and 0 deletions

18
mastodon/db.tf Normal file
View File

@ -0,0 +1,18 @@
module "mastodon-redis" {
name = "mastodon-redis"
source = "../modules/container"
image = "redis:alpine"
networks = ["mastodon"]
keep_image = true
resource = {
memory = 256
memory_swap = 256
}
}
module "mastodon-db" {
source = "../modules/postgres"
name = "mastodon"
password = var.db-password
}

94
mastodon/main.tf Normal file
View File

@ -0,0 +1,94 @@
module "mastodon-web" {
name = "mastodon-web"
source = "../modules/container"
image = "tootsuite/mastodon:v4.0"
networks = ["mastodon", "traefik", "external", "postgres"]
env = concat(local.env,[
"MAX_THREADS=4",
"WEB_CONCURRENCY=5"
])
command = [
"bash",
"-c",
"rm -f /mastodon/tmp/pids/server.pid; bundle exec rake db:migrate; bundle exec rails s -p 3000"
]
volumes = [{
container_path = "/mastodon/public/system"
host_path = "/mnt/xwing/data/mastodon"
}]
web = {
expose = "true"
host = "tatooine.club"
port = 3000
}
resource = {
memory = 1024
memory_swap = 1024
}
}
module "mastodon-streaming" {
name = "mastodon-streaming"
source = "../modules/container"
image = "tootsuite/mastodon:v4.0"
# 24 threads for Streaming
env = concat(local.env,[
"DB_POOL=8",
"STREAMING_CLUSTER_NUM=4"
])
networks = ["postgres", "external", "mastodon"]
command = [
"node",
"./streaming"
]
web = {
expose = "false"
}
resource = {
memory = 1024
memory_swap = 1024
}
}
module "mastodon-sidekiq" {
name = "mastodon-sidekiq"
source = "../modules/container"
image = "tootsuite/mastodon:v4.0"
env = concat(local.env,[
"DB_POOL=50"
])
web = {
expose = "false"
}
networks = ["postgres", "external", "mastodon"]
command = [
"bundle",
"exec",
"sidekiq"
]
volumes = [{
container_path = "/mastodon/public/system"
host_path = "/mnt/xwing/data/mastodon"
}]
resource = {
memory = 1024
memory_swap = 1024
}
}

5
mastodon/network.tf Normal file
View File

@ -0,0 +1,5 @@
resource "docker_network" "mastodon" {
name = "mastodon"
driver = "bridge"
internal = true
}

10
mastodon/provider.tf Normal file
View File

@ -0,0 +1,10 @@
terraform {
required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
}
docker = {
source = "kreuzwerker/docker"
}
}
}

3
mastodon/vars.tf Normal file
View File

@ -0,0 +1,3 @@
variable "db-password" {
type = string
}

View File

@ -176,3 +176,8 @@ data "pass_password" "navidrome-spotify-secret" {
path = "Nebula/navidrome-spotify-secret"
}
data "pass_password" "mastodon-db-password" {
path = "Nebula/MASTODON_DB_PASSWORD"
}