Add syncthing

Signed-off-by: main <magic_rb@redalder.org>
This commit is contained in:
main 2022-04-26 09:48:03 +02:00
parent ca34d4229c
commit fd57407030
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E
6 changed files with 192 additions and 1 deletions

21
containers/syncthing.nix Normal file
View file

@ -0,0 +1,21 @@
{ nglib, nixpkgs }:
nglib.makeSystem {
inherit nixpkgs;
system = "x86_64-linux";
name = "ra-systems-syncthing";
config = ({ pkgs, ... }:
{
dumb-init = {
enable = true;
type.services = { };
};
init.services.syncthing = {
shutdownOnExit = true;
};
services.syncthing = {
enable = true;
guiAddress = "http://0.0.0.0:8384/";
};
});
}

View file

@ -335,6 +335,12 @@ EOF
destination_name = "home-assistant" destination_name = "home-assistant"
local_bind_port = 8003 local_bind_port = 8003
} }
upstreams {
destination_name = "syncthing"
local_bind_port = 8004
}
} }
} }
@ -422,6 +428,10 @@ upstream home-assistant {
server {{ env "NOMAD_UPSTREAM_ADDR_home-assistant" }}; server {{ env "NOMAD_UPSTREAM_ADDR_home-assistant" }};
} }
upstream syncthing {
server {{ env "NOMAD_UPSTREAM_ADDR_syncthing" }};
}
server { server {
listen 8096; listen 8096;
@ -432,8 +442,10 @@ server {
client_max_body_size 100M; client_max_body_size 100M;
location /jellyfin { location /jellyfin {
location /syncthing/ {
include /local/headers.conf; include /local/headers.conf;
proxy_pass http://jellyfin;
proxy_pass http://syncthing/;
} }
location ~ "^/(static/icons/|static/fonts/|static/translations/|static/images/|static/panels/|static/polyfills|api/|auth/|frontend_latest/|frontend_es5/|local/|lovelace|map|config|developer-tools|history|logbook|profile|states|hassio|onboarding.html|service_worker.js|authorize.html|manifest.json)" { location ~ "^/(static/icons/|static/fonts/|static/translations/|static/images/|static/panels/|static/polyfills|api/|auth/|frontend_latest/|frontend_es5/|local/|lovelace|map|config|developer-tools|history|logbook|profile|states|hassio|onboarding.html|service_worker.js|authorize.html|manifest.json)" {

View file

@ -0,0 +1,101 @@
job "syncthing" {
datacenters = [ "homelab-1" ]
type = "service"
group "syncthing" {
count = 1
volume "syncthing-data" {
type = "csi"
source = "syncthing-data"
read_only = false
attachment_mode = "file-system"
access_mode = "single-node-writer"
}
volume "syncthing-config" {
type = "csi"
source = "syncthing-config"
read_only = false
attachment_mode = "file-system"
access_mode = "single-node-writer"
}
volume "syncthing-storage" {
type = "csi"
source = "syncthing-storage"
read_only = false
attachment_mode = "file-system"
access_mode = "single-node-writer"
}
network {
mode = "bridge"
}
service {
name = "syncthing"
port = "8384"
## Syncthing with auth returns 402: Unauthorized and Nomad interprets it as
## service failure.
# check {
# type = "http"
# address_mode = "alloc"
# path = "/"
# port = "8384"
# interval = "10s"
# timeout = "10s"
# }
connect {
sidecar_service {}
sidecar_task {
resources {
cpu = 75
memory = 48
}
config {
memory_hard_limit = 96
}
}
}
}
task "syncthing" {
driver = "docker"
config {
image = "ra-systems-syncthing:local"
}
resources {
cpu = 128
memory = 128
}
volume_mount {
volume = "syncthing-data"
destination = "/var/syncthing/data"
read_only = false
}
volume_mount {
volume = "syncthing-config"
destination = "/var/syncthing/config"
read_only = false
}
volume_mount {
volume = "syncthing-storage"
destination = "/var/syncthing/storage"
read_only = false
}
}
}
}

View file

@ -0,0 +1,19 @@
type = "csi"
id = "syncthing-config"
name = "syncthing-config"
plugin_id = "nfs"
capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
context {
server = "10.64.1.201"
share = "/var/nfs/syncthing/config"
}
mount_options {
fs_type = "nfs"
mount_flags = [ "nolock", "hard" ]
}

View file

@ -0,0 +1,19 @@
type = "csi"
id = "syncthing-data"
name = "syncthing-data"
plugin_id = "nfs"
capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
context {
server = "10.64.1.201"
share = "/var/nfs/syncthing/data"
}
mount_options {
fs_type = "nfs"
mount_flags = [ "nolock", "hard" ]
}

View file

@ -0,0 +1,19 @@
type = "csi"
id = "syncthing-storage"
name = "syncthing-storage"
plugin_id = "nfs"
capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
context {
server = "10.64.1.201"
share = "/var/nfs/syncthing/storage"
}
mount_options {
fs_type = "nfs"
mount_flags = [ "nolock", "hard" ]
}