spaceapi \o/

This commit is contained in:
Jan Koppe 2024-01-27 13:14:36 +01:00
parent 6033ca423e
commit 3769e86703
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
6 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,65 @@
data "docker_registry_image" "spaceapi" {
name = "git.chaoswest.tv/cwtv/spaceapi:latest"
}
data "docker_network" "traefik" {
name = "traefik"
}
locals {
labels = {
"shepherd.auto-update" = "true",
"traefik.enable" = "true"
"traefik.http.services.spaceapi.loadbalancer.server.port" = "8000",
"traefik.http.routers.spaceapi.rule" = "Host(`api.chaoswest.tv`)||Host(`api.montage2.de`)",
"traefik.http.routers.spaceapi.tls" = "true",
"traefik.http.routers.spaceapi.tls.certresolver" = "default",
}
}
resource "docker_service" "spaceapi" {
name = "spaceapi"
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.spaceapi.name}@${data.docker_registry_image.spaceapi.sha256_digest}"
env = {
WORKERS = "12"
}
}
}
}
data "hetznerdns_zone" "montage2_de" {
name = "montage2.de"
}
resource "hetznerdns_record" "montage2_de" {
zone_id = data.hetznerdns_zone.montage2_de.id
name = "api"
value = "ax41-1.fsn.mon2.de."
type = "CNAME"
}
data "hetznerdns_zone" "chaoswest_tv" {
name = "chaoswest.tv"
}
resource "hetznerdns_record" "chaoswest_tv" {
zone_id = data.hetznerdns_zone.chaoswest_tv.id
name = "api"
value = "ax41-1.fsn.mon2.de."
type = "CNAME"
}

View File

View File

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

@ -25,6 +25,7 @@
| <a name="module_jitsi"></a> [jitsi](#module\_jitsi) | ../../modules/swarm/jitsi | n/a |
| <a name="module_shepherd"></a> [shepherd](#module\_shepherd) | ../../modules/swarm/shepherd | n/a |
| <a name="module_shit"></a> [shit](#module\_shit) | ../../modules/swarm/shit | n/a |
| <a name="module_spaceapi"></a> [spaceapi](#module\_spaceapi) | ../../modules/swarm/spaceapi | n/a |
| <a name="module_traefik"></a> [traefik](#module\_traefik) | ../../modules/swarm/traefik | n/a |
## Resources

View File

@ -30,6 +30,10 @@ module "shit" {
source = "../../modules/swarm/shit"
}
module "spaceapi" {
source = "../../modules/swarm/spaceapi"
}
module "forgejo" {
source = "../../modules/swarm/forgejo"
}