move hedgedoc to pad.chaoswest.tv; switch to sqlite after mysql imploded

This commit is contained in:
Jan Koppe 2024-11-06 15:12:42 +01:00
parent 3a900084b3
commit b3700eb982
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
1 changed files with 10 additions and 43 deletions

View File

@ -2,10 +2,6 @@ data "docker_registry_image" "hedgedoc" {
name = "quay.io/hedgedoc/hedgedoc:1.9.9" name = "quay.io/hedgedoc/hedgedoc:1.9.9"
} }
data "docker_registry_image" "hedgedoc_mysql" {
name = "mysql:8"
}
data "docker_network" "traefik" { data "docker_network" "traefik" {
name = "traefik" name = "traefik"
} }
@ -20,8 +16,6 @@ resource "docker_network" "hedgedoc" {
} }
} }
locals { locals {
labels = { labels = {
"shepherd.auto-update" = "true", "shepherd.auto-update" = "true",
@ -31,40 +25,8 @@ locals {
"traefik.http.routers.hedgedoc.tls" = "true", "traefik.http.routers.hedgedoc.tls" = "true",
"traefik.http.routers.hedgedoc.tls.certresolver" = "default", "traefik.http.routers.hedgedoc.tls.certresolver" = "default",
"traefik.http.routers.hedgedoc.middlewares" = "hedgedoc-redirect", "traefik.http.routers.hedgedoc.middlewares" = "hedgedoc-redirect",
"traefik.http.middlewares.hedgedoc-redirect.redirectregex.regex" = "^https://pad.chaoswest.tv/(.*)", "traefik.http.middlewares.hedgedoc-redirect.redirectregex.regex" = "^https://pad.montage2.de/(.*)",
"traefik.http.middlewares.hedgedoc-redirect.redirectregex.replacement" = "https://pad.montage2.de/$$${1}", # double escaping is necessary here "traefik.http.middlewares.hedgedoc-redirect.redirectregex.replacement" = "https://pad.chaoswest.tv/$$${1}", # double escaping is necessary here
}
}
resource "docker_service" "hedgedoc_mysql" {
name = "hedgedoc-mysql"
task_spec {
networks_advanced {
name = docker_network.hedgedoc.id
}
container_spec {
image = "${data.docker_registry_image.hedgedoc_mysql.name}@${data.docker_registry_image.hedgedoc_mysql.sha256_digest}"
args = [
"--character-set-server=utf8mb4",
"--collation-server=utf8mb4_unicode_ci"
]
env = {
MYSQL_RANDOM_ROOT_PASSWORD = "1",
MYSQL_DATABASE = "hedgedoc",
MYSQL_USER = "hedgedoc",
MYSQL_PASSWORD = "hedgedoc",
}
mounts {
target = "/var/lib/mysql/"
source = "/mnt/data/pad/mysql/"
type = "bind"
}
}
} }
} }
@ -94,14 +56,13 @@ resource "docker_service" "hedgedoc" {
env = merge({ env = merge({
for k, v in var.secrets : k => v for k, v in var.secrets : k => v
}, { }, {
CMD_DB_URL = "mysql://hedgedoc:hedgedoc@hedgedoc-mysql:3306/hedgedoc", CMD_DB_URL = "sqlite:/hedgedoc/db/hedgedoc.sqlite",
CMD_DOMAIN = "pad.montage2.de", CMD_DOMAIN = "pad.chaoswest.tv",
CMD_URL_ADDPORT = "false", CMD_URL_ADDPORT = "false",
CMD_PROTOCOL_USESSL = "true", CMD_PROTOCOL_USESSL = "true",
CMD_EMAIL = "false", CMD_EMAIL = "false",
CMD_ALLOW_EMAIL_REGISTER = "false", CMD_ALLOW_EMAIL_REGISTER = "false",
CMD_ALLOW_FREEURL = "true", CMD_ALLOW_FREEURL = "true",
CMD_GITLAB_BASEURL = "https://gitlab.montage2.de",
CMD_OAUTH2_PROVIDERNAME = "authentik", CMD_OAUTH2_PROVIDERNAME = "authentik",
CMD_OAUTH2_SCOPE = "openid email profile", CMD_OAUTH2_SCOPE = "openid email profile",
CMD_OAUTH2_USER_PROFILE_URL = "https://authentik.montage2.de/application/o/userinfo/", CMD_OAUTH2_USER_PROFILE_URL = "https://authentik.montage2.de/application/o/userinfo/",
@ -112,6 +73,12 @@ resource "docker_service" "hedgedoc" {
CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR = "email", CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR = "email",
}) })
mounts {
target = "/hedgedoc/db"
source = "/mnt/data/pad/db"
type = "bind"
}
mounts { mounts {
target = "/hedgedoc/public/uploads" target = "/hedgedoc/public/uploads"
source = "/mnt/data/pad/uploads" source = "/mnt/data/pad/uploads"