add ontime, with remains of failed authentication

This commit is contained in:
Jan Koppe 2025-05-29 13:25:58 +02:00
parent 851de2cb4a
commit 939152e771
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
6 changed files with 130 additions and 15 deletions

View File

@ -0,0 +1,86 @@
data "docker_registry_image" "primary" {
name = "getontime/ontime:latest"
}
data "docker_network" "traefik" {
name = "traefik"
}
locals {
name = "ontime${var.ontime_identifier}"
public_paths = [
"/ontime-logo.png",
"/favicon.ico",
"/data",
"/assets",
"/timer",
"/minimal",
"/clock",
"/backstage",
"/countdown",
"/studio",
"/timeline",
"/api/poll",
"/api/version",
]
public_paths_rule = join(" || ", [for path in local.public_paths : "PathPrefix(`${path}`)"])
labels = {
"shepherd.auto-update" = "true",
"traefik.enable" = "true"
"traefik.http.services.${local.name}.loadbalancer.server.port" = "4001",
"traefik.http.routers.${local.name}.rule" = "Host(`${local.name}.chaoswest.tv`)",
"traefik.http.routers.${local.name}.tls" = "true",
"traefik.http.routers.${local.name}.tls.certresolver" = "default",
"traefik.http.routers.${local.name}.priority" = "1",
## Authentication was tried, but ontime needs a WebSocket connection for almost everything, and we can't really secure this.
## So, we'll be using the pincode feature of ontime and just deploy it only for the time needed.
#"traefik.http.routers.${local.name}.middlewares" = "auth-ontime@file",
#"traefik.http.services.${local.name}-open.loadbalancer.server.port" = "4001",
#"traefik.http.routers.${local.name}-open.rule" = "Host(`${local.name}.chaoswest.tv`) && (${local.public_paths_rule})",
#"traefik.http.routers.${local.name}-open.tls" = "true",
#"traefik.http.routers.${local.name}-open.tls.certresolver" = "default",
#"traefik.http.routers.${local.name}-open.priority" = "2",
}
}
resource "docker_service" "primary" {
name = local.name
dynamic "labels" {
for_each = local.labels
content {
label = labels.key
value = labels.value
}
}
task_spec {
networks_advanced {
name = data.docker_network.traefik.id
}
container_spec {
image = "${data.docker_registry_image.primary.name}@${data.docker_registry_image.primary.sha256_digest}"
mounts {
target = "/data/"
source = "/mnt/data/${local.name}"
type = "bind"
}
}
}
}
data "hetznerdns_zone" "primary" {
name = "chaoswest.tv"
}
resource "hetznerdns_record" "www" {
zone_id = data.hetznerdns_zone.primary.id
name = local.name
value = "ax41-1.fsn.mon2.de."
type = "CNAME"
}

View File

View File

@ -0,0 +1,4 @@
variable "ontime_identifier" {
type = string
default = ""
}

View File

@ -0,0 +1,13 @@
terraform {
required_version = "1.5.5"
required_providers {
hetznerdns = {
source = "timohirt/hetznerdns"
version = "~>2.2"
}
docker = {
source = "kreuzwerker/docker"
version = "~>3.0"
}
}
}

View File

@ -1,17 +1,21 @@
---
http:
routers:
dashboard-secure:
rule: Host(`traefik.montage2.de`)
service: api@internal
tls:
certResolver: default
middlewares:
- auth-hausmeister
entryPoints:
- https
middlewares:
auth-hausmeister:
basicAuth:
users:
- "hausmeister:$2y$10$.ewz0qQlm.mT/LRzuSwRYOmytRj7K3ojcxFsvkgrMKFicbA5EtKV."
routers:
dashboard-secure:
rule: Host(`traefik.montage2.de`)
service: api@internal
tls:
certResolver: default
middlewares:
- auth-hausmeister
entryPoints:
- https
middlewares:
auth-hausmeister:
basicAuth:
users:
- "hausmeister:$2y$10$.ewz0qQlm.mT/LRzuSwRYOmytRj7K3ojcxFsvkgrMKFicbA5EtKV."
auth-ontime:
basicAuth:
users:
- "cwtv:$apr1$EZhof.oe$SEgKIX98pcki/zME/sLVd1"

View File

@ -50,3 +50,11 @@ module "forgejo" {
module "prometheus" {
source = "../../modules/swarm/prometheus"
}
# Only deploy when needed due to lacking authentication/security!
#module "ontime1" {
# source = "../../modules/swarm/ontime"
#
# ontime_identifier = "1"
#}