98 lines
2.9 KiB
Nix
98 lines
2.9 KiB
Nix
{ config, lib, pkgs, ... }: let
|
|
|
|
hostPort = 9007;
|
|
|
|
subdomain = "ai";
|
|
|
|
name = "openwebui";
|
|
|
|
in {
|
|
|
|
options.sysconfig.docker.openwebui.enable = with lib; mkOption {
|
|
type = with types; bool;
|
|
default = false;
|
|
};
|
|
|
|
config = lib.mkIf (config.sysconfig.docker.openwebui.enable && config.sysconfig.docker.enable) {
|
|
|
|
virtualisation.oci-containers.containers.openwebui = {
|
|
image = "ghcr.io/open-webui/open-webui:v0.7.2";
|
|
|
|
# unstable, waiting for 26.05
|
|
#pull = "newer";
|
|
|
|
hostname = "${subdomain}.esotericbytes.com";
|
|
|
|
networks = [
|
|
"docker-main"
|
|
];
|
|
|
|
/*ports = [
|
|
"${builtins.toString hostPort}:8080"
|
|
];*/
|
|
|
|
volumes = [
|
|
"vol_openwebui:/app/backend/data"
|
|
];
|
|
|
|
labels = {
|
|
"traefik.enable" = "true";
|
|
"traefik.http.routers.${name}.entrypoints" = "localsecure";
|
|
"traefik.http.routers.${name}.rule" = "Host(`${subdomain}.esotericbytes.com`)";
|
|
"traefik.http.routers.${name}.service" = "${name}";
|
|
"traefik.http.routers.${name}.tls.certResolver" = "cloudflare";
|
|
|
|
"traefik.http.services.${name}.loadbalancer.server.port" = "8080";
|
|
};
|
|
|
|
extraOptions = lib.mkIf config.sysconfig.docker.nvidia [
|
|
"--device=nvidia.com/gpu=all"
|
|
];
|
|
|
|
environment = {
|
|
};
|
|
};
|
|
|
|
systemd.services."docker-openwebui" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 90 "always";
|
|
RestartMaxDelaySec = lib.mkOverride 90 "1m";
|
|
RestartSec = lib.mkOverride 90 "100ms";
|
|
RestartSteps = lib.mkOverride 90 9;
|
|
};
|
|
after = [
|
|
"docker-network-setup.service"
|
|
"docker-volume-openwebui.service"
|
|
];
|
|
requires = [
|
|
"docker-network-setup.service"
|
|
"docker-volume-openwebui.service"
|
|
];
|
|
partOf = [
|
|
"docker-compose-openwebui-root.target"
|
|
];
|
|
wantedBy = [
|
|
"docker-compose-openwebui-root.target"
|
|
];
|
|
};
|
|
|
|
systemd.services."docker-volume-openwebui" = {
|
|
path = [ pkgs.docker ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
script = ''
|
|
docker volume inspect vol_openwebui || docker volume create vol_openwebui --driver=local
|
|
'';
|
|
partOf = [ "docker-compose-openwebui-root.target" ];
|
|
wantedBy = [ "docker-compose-openwebui-root.target" ];
|
|
};
|
|
|
|
systemd.targets."docker-compose-openwebui-root" = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
|
|
};
|
|
}
|