From 87d5a87067a5a834fa6b6bf6fe7791953637ca48 Mon Sep 17 00:00:00 2001 From: Magic_RB Date: Thu, 15 Jun 2023 23:06:35 +0200 Subject: [PATCH] Add terranix config for jellyfin Signed-off-by: Magic_RB --- terranix/containers/jellyfin/default.nix | 35 +++++++ terranix/containers/jellyfin/job.hcl | 123 +++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 terranix/containers/jellyfin/default.nix create mode 100644 terranix/containers/jellyfin/job.hcl diff --git a/terranix/containers/jellyfin/default.nix b/terranix/containers/jellyfin/default.nix new file mode 100644 index 0000000..b1a73e2 --- /dev/null +++ b/terranix/containers/jellyfin/default.nix @@ -0,0 +1,35 @@ +{ elib, ... }: +let + inherit (elib) + nfsVolume + nomadJob; +in +{ + resource."nomad_volume"."jellyfin-cache" = nfsVolume { + volume_name = "jellyfin-cache"; + access_mode = "single-node-writer"; + server = "blowhole.hosts.in.redalder.org"; + share = "/mnt/kyle/infrastructure/jellyfin/cache"; + mount_flags = [ "hard" "vers=4.2" "rsize=131072" "wsize=131072" "async" ]; + }; + + resource."nomad_volume"."jellyfin-config" = nfsVolume { + volume_name = "jellyfin-config"; + access_mode = "single-node-writer"; + server = "blowhole.hosts.in.redalder.org"; + share = "/mnt/kyle/infrastructure/jellyfin/config"; + mount_flags = [ "hard" "vers=4.2" "rsize=131072" "wsize=131072" "async" ]; + }; + + resource."nomad_volume"."jellyfin-media" = nfsVolume { + volume_name = "jellyfin-media"; + access_mode = "single-node-writer"; + server = "blowhole.hosts.in.redalder.org"; + share = "/mnt/kyle/infrastructure/jellyfin/media"; + mount_flags = [ "hard" "vers=4.2" "rsize=131072" "wsize=131072" "async" ]; + }; + + resource."nomad_job"."jellyfin" = nomadJob { + jobspec = ./job.hcl; + }; +} diff --git a/terranix/containers/jellyfin/job.hcl b/terranix/containers/jellyfin/job.hcl new file mode 100644 index 0000000..f79fe14 --- /dev/null +++ b/terranix/containers/jellyfin/job.hcl @@ -0,0 +1,123 @@ +job "jellyfin" { + datacenters = [ "homelab-1" ] + type = "service" + + constraint { + attribute = "${attr.unique.hostname}" + value = "blowhole" + } + + group "jellyfin" { + count = 1 + + volume "jellyfin-cache" { + type = "csi" + source = "jellyfin-cache" + read_only = false + + attachment_mode = "file-system" + access_mode = "single-node-writer" + } + + volume "jellyfin-config" { + type = "csi" + source = "jellyfin-config" + read_only = false + + attachment_mode = "file-system" + access_mode = "single-node-writer" + } + + volume "jellyfin-media" { + type = "csi" + source = "jellyfin-media" + read_only = false + + attachment_mode = "file-system" + access_mode = "single-node-writer" + } + + volume "jellyfin-mount" { + type = "host" + read_only = true + source = "jellyfin-mount" + } + + network { + mode = "bridge" + + port "http" { + to = 8096 + } + } + + service { + name = "jellyfin" + port = "8096" + + check { + type = "http" + address_mode = "alloc" + path = "/" + port = "8096" + interval = "10s" + timeout = "10s" + } + + connect { + sidecar_service {} + + sidecar_task { + resources { + cpu = 75 + memory = 48 + memory_max = 96 + } + } + } + } + + task "jellyfin" { + driver = "docker" + + config { + image = "jellyfin/jellyfin@sha256:73501b70b0e884e5815d8f03d22973513ae7cadbcd8dba95da60e1d7c82dac7b" + + # devices = [ + # { + # host_path = "/dev/dri/renderD128" + # container_path = "/dev/dri/renderD128" + # }, + # { + # host_path = "/dev/dri/card0" + # container_path = "/dev/dri/card0" + # } + # ] + } + + resources { + cpu = 1024 + memory = 1024 + memory_max = 2048 + } + + volume_mount { + volume = "jellyfin-cache" + destination = "/cache" + read_only = false + } + + volume_mount { + volume = "jellyfin-config" + destination = "/config" + read_only = false + } + + volume_mount { + volume = "jellyfin-media" + destination = "/media" + read_only = false + } + } + } +}