aboutsummaryrefslogtreecommitdiff
path: root/modules/containers/lubelogger
diff options
context:
space:
mode:
authortdback <tyler@tdback.net>2025-01-26 11:31:39 -0500
committertdback <tyler@tdback.net>2025-01-26 11:31:39 -0500
commit1b40ddcb978dec8cf52a82319f1f8b4e4eedd3f8 (patch)
treeaf7b6b2ff316e42fa8c59ff772970a16a3b8c4cb /modules/containers/lubelogger
parenta7c3d07078d0ca67afadd6fb24ab4b60b38c1109 (diff)
containers: reworked each container to be a standalone module
Diffstat (limited to 'modules/containers/lubelogger')
-rw-r--r--modules/containers/lubelogger/default.nix102
1 files changed, 76 insertions, 26 deletions
diff --git a/modules/containers/lubelogger/default.nix b/modules/containers/lubelogger/default.nix
index 6ff2b0d..c7ca98f 100644
--- a/modules/containers/lubelogger/default.nix
+++ b/modules/containers/lubelogger/default.nix
@@ -1,34 +1,84 @@
-{ ... }:
+{
+ config,
+ lib,
+ ...
+}:
+with lib;
let
- directory = "/opt/lubelogger";
- port = "8889";
+ service = "lubelogger";
+ cfg = config.modules.containers.${service};
in
{
- systemd.tmpfiles.rules = builtins.map (x: "d ${x} 0755 share share - -") [ directory ];
+ options.modules.containers.${service} = {
+ enable = mkEnableOption service;
+ user = mkOption {
+ default = "share";
+ type = types.str;
+ };
+ group = mkOption {
+ default = "share";
+ type = types.str;
+ };
+ port = mkOption {
+ default = 8889;
+ type = types.int;
+ };
+ url = mkOption {
+ default = null;
+ type = types.str;
+ };
+ configDir = mkOption {
+ default = "/opt/${service}";
+ type = types.str;
+ };
+ };
+
+ config = mkIf cfg.enable {
+ users.users.${cfg.user} = {
+ isSystemUser = true;
+ group = cfg.group;
+ };
+
+ users.groups.${cfg.group} = { };
- virtualisation.oci-containers.containers.lubelogger = {
- image = "ghcr.io/hargata/lubelogger:latest";
- autoStart = true;
- ports = [ "${port}:8080" ];
- volumes = [
- "${directory}/config:/App/config"
- "${directory}/data:/App/data"
- "${directory}/translations:/App/wwwroot/translations"
- "${directory}/documents:/App/wwwroot/documents"
- "${directory}/images:/App/wwwroot/images"
- "${directory}/temp:/App/wwwroot/temp"
- "${directory}/log:/App/log"
- "${directory}/keys:/root/.aspnet/DataProtection-Keys"
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
];
- environment = {
- LC_ALL = "en_US.UTF-8";
- LANG = "en_US.UTF-8";
- LUBELOGGER_ALLOWED_FILE_EXTENSIONS = "*";
+
+ services.caddy = {
+ enable = true;
+ virtualHosts = {
+ ${cfg.url}.extraConfig = ''
+ encode zstd gzip
+ reverse_proxy http://localhost:${builtins.toString cfg.port}
+ '';
+ };
};
- };
- services.caddy.virtualHosts."garage.brownbread.net".extraConfig = ''
- encode zstd gzip
- reverse_proxy http://localhost:${port}
- '';
+ systemd.tmpfiles.rules = builtins.map (f: "d ${f} 0755 ${cfg.user} ${cfg.group} - -") [
+ cfg.configDir
+ ];
+
+ virtualisation.oci-containers.containers.${service} = {
+ image = "ghcr.io/hargata/lubelogger:latest";
+ autoStart = true;
+ ports = [ "${builtins.toString cfg.port}:8080" ];
+ volumes = [
+ "${cfg.configDir}/config:/App/config"
+ "${cfg.configDir}/data:/App/data"
+ "${cfg.configDir}/translations:/App/wwwroot/translations"
+ "${cfg.configDir}/documents:/App/wwwroot/documents"
+ "${cfg.configDir}/images:/App/wwwroot/images"
+ "${cfg.configDir}/temp:/App/wwwroot/temp"
+ "${cfg.configDir}/log:/App/log"
+ "${cfg.configDir}/keys:/root/.aspnet/DataProtection-Keys"
+ ];
+ environment = {
+ LC_ALL = "en_US.UTF-8";
+ LANG = "en_US.UTF-8";
+ LUBELOGGER_ALLOWED_FILE_EXTENSIONS = "*";
+ };
+ };
+ };
}