Use docker instead of nspawn to host onlyoffice

This commit is contained in:
SebastianStork 2024-09-17 21:38:02 +02:00
parent 982dc99e7a
commit 18bbe1fd27
5 changed files with 53 additions and 61 deletions

View file

@ -0,0 +1,48 @@
{ config, pkgs, ... }:
{
sops.secrets = {
"container/onlyoffice/tailscale-auth-key" = { };
"container/onlyoffice/jwt-secret" = { };
};
virtualisation.oci-containers.containers = {
onlyoffice = {
image = "onlyoffice/documentserver";
environmentFiles = [
# Contains "JWT_SECRET=<token>"
config.sops.secrets."container/onlyoffice/jwt-secret".path
];
};
tailscale-onlyoffice =
let
configPath = pkgs.writeTextFile {
name = "config";
destination = "/tailscale-serve.json";
text = builtins.toJSON {
TCP."443".HTTPS = true;
Web."onlyoffice.${config.networking.domain}:443".Handlers."/".Proxy = "http://127.0.0.1:80";
};
};
in
{
image = "ghcr.io/tailscale/tailscale:latest";
environment = {
TS_HOSTNAME = "onlyoffice";
TS_STATE_DIR = "/var/lib/tailscale";
TS_SERVE_CONFIG = "/config/tailscale-serve.json";
TS_USERSPACE = "true"; # https://github.com/tailscale/tailscale/issues/11372
};
environmentFiles = [
# Contains "TS_AUTHKEY=<token>"
config.sops.secrets."container/onlyoffice/tailscale-auth-key".path
];
volumes = [
"/var/lib/tailscale-onlyoffice:/var/lib/tailscale"
"${configPath}:/config"
];
extraOptions = [ "--network=container:onlyoffice" ];
dependsOn = [ "onlyoffice" ];
};
};
}