From bf60b7d466f4137d37a84b980672bcabdf63438f Mon Sep 17 00:00:00 2001 From: mc-fucker Date: Thu, 28 Mar 2024 17:20:47 +0100 Subject: [PATCH] added template for podman with postgresql --- templates/podman_with_psql.nix | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 templates/podman_with_psql.nix diff --git a/templates/podman_with_psql.nix b/templates/podman_with_psql.nix new file mode 100644 index 0000000..b8369d2 --- /dev/null +++ b/templates/podman_with_psql.nix @@ -0,0 +1,56 @@ +{ config, lib, ... }: +let + cfg = import ./vars.nix; + name = "XXX"; + dbport = cfg.XXX.dbport; + db_host = cfg.podman.hostIP; + port = cfg.XXX.port; + domain = cfg.XXX.domain; +in +{ + imports = [ + #./podman.nix + ./podman-postgresql.nix # for the database + ./nginx.nix # for the webserver + ]; + + sops.secrets."${name}/db" = {}; + sops.secrets."${name}/env" = {}; + + services.podman-postgresql."${name}" = { + enable = true; + image = "docker.io/library/postgres:16-alpine"; + port = (lib.strings.toInt dbport); + passwordFile = config.sops.secrets."${name}/db".path; + }; + + virtualisation.oci-containers.containers.XXX = { + image = "XXX"; + environment = { + TZ = "Europe/Berlin"; + }; + environmentFiles = [ config.sops.secrets."${name}/env".path ]; + ports = [ + "${port}:80" + ]; + volumes = [ + "/var/lib/XXX:/data" + ]; + extraOptions = cfg.podman.extraOptions; + }; + + services.nginx.virtualHosts.${domain} = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://localhost:${port}"; + proxyWebsockets = true; + }; + extraConfig = '' + access_log /var/log/nginx/${domain}_access.log; + error_log /var/log/nginx/${domain}_error.log; + ''; + }; + +} +# vim: set et ts=2 sw=2 ai: