diff options
| -rw-r--r-- | machines/renard/default.nix | 2 | ||||
| -rw-r--r-- | services/goatcounter.nix | 63 |
2 files changed, 65 insertions, 0 deletions
diff --git a/machines/renard/default.nix b/machines/renard/default.nix index c3fb0fe..d9871c3 100644 --- a/machines/renard/default.nix +++ b/machines/renard/default.nix @@ -16,6 +16,7 @@ ../../services/miniflux.nix ../../services/shiori.nix ../../services/matrix.nix + ../../services/goatcounter.nix ../../services/irc ]; @@ -44,6 +45,7 @@ "mel" "shorest" "matrix" + "goat" ]; }; }; diff --git a/services/goatcounter.nix b/services/goatcounter.nix new file mode 100644 index 0000000..b463b27 --- /dev/null +++ b/services/goatcounter.nix @@ -0,0 +1,63 @@ +{ + me, + pkgs, + auxiliaryPkgs, + ... +}: + +let + inherit (pkgs) dockerTools; + inherit (auxiliaryPkgs) common; + + goatcounter = pkgs.goatcounter; + + goatcounterLocalPort = 7151; + goatcounterDir = "/srv/goatcounter"; + + goatcounterImage = dockerTools.streamLayeredImage { + name = "goatcounter"; + tag = goatcounter.version; + fromImage = common.alpine.base; + contents = [ goatcounter ]; + }; + +in +{ + foundation.services.goatcounter = { + image = goatcounterImage; + ports = [ + [ + goatcounterLocalPort + 8080 + ] + ]; + + volumes = [ + [ + "${goatcounterDir}" + "/goatcounter" + ] + ]; + + entrypoint = "${goatcounter}/bin/goatcounter"; + cmd = [ + "serve" + "-automigrate" + "-listen=:8080" + "-tls=none" + "-db=sqlite+/goatcounter/db.sqlite3" + ]; + }; + + services.nginx.virtualHosts."goat.rnrd.eu" = { + useACMEHost = "rnrd.eu"; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:${toString goatcounterLocalPort}/"; + proxyWebsockets = true; + }; + extraConfig = '' + access_log /var/log/nginx/goat.access.log json_combined; + ''; + }; +} |
