add mongodb

This commit is contained in:
Yan Lin 2026-01-10 14:02:19 +01:00
parent 35be9ff89a
commit 2998cc763c
4 changed files with 32 additions and 2 deletions

View file

@ -7,7 +7,18 @@ let
systemTZ = config.time.timeZone; systemTZ = config.time.timeZone;
in in
{ {
# Container definitions for hs host # Container definitions for nfss host
virtualisation.oci-containers.containers = { virtualisation.oci-containers.containers = {
mongodb = {
image = "docker.io/mongo:7";
volumes = [ "/var/lib/mongodb:/data/db" ];
environment = { TZ = systemTZ; };
environmentFiles = [ "/etc/mongodb-env" ];
ports = [ "27017:27017" ];
extraOptions = [ "--network=podman" ];
autoStart = true;
};
}; };
} }

View file

@ -70,5 +70,21 @@
}; };
}; };
tcp = {
routers.mongodb = {
rule = "HostSNI(`mongodb.yanlincs.com`)";
service = "mongodb";
entrypoints = [ "mongodb" ];
tls = {
certResolver = "cloudflare";
domains = [{ main = "*.yanlincs.com"; }];
};
};
services.mongodb = {
loadBalancer.servers = [{ address = "nfss.yanlincs.com:27017"; }];
};
};
}; };
} }

View file

@ -40,7 +40,7 @@
useDHCP = true; # VPS typically use DHCP useDHCP = true; # VPS typically use DHCP
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [ 22 80 443 22000 ]; allowedTCPPorts = [ 22 80 443 22000 27017 ];
allowedUDPPorts = [ 22000 ]; allowedUDPPorts = [ 22000 ];
trustedInterfaces = [ "tailscale0" ]; trustedInterfaces = [ "tailscale0" ];
}; };

View file

@ -26,6 +26,9 @@
websecure = { websecure = {
address = ":443"; address = ":443";
}; };
mongodb = {
address = ":27017";
};
}; };
# Certificate resolver using Cloudflare DNS challenge # Certificate resolver using Cloudflare DNS challenge