[Nix] Adds MCP config.
This commit is contained in:
30
system/hosts/mcp/containers/lib.nix
Normal file
30
system/hosts/mcp/containers/lib.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
config:
|
||||
let
|
||||
hostRule = host: "Host(`${host}.${config.domainName}`)";
|
||||
localNetRule = "ClientIP(`${config.localNet}`)";
|
||||
localHostRule = host: "${localNetRule} && ${hostRule host}";
|
||||
in
|
||||
{
|
||||
inherit hostRule localNetRule localHostRule;
|
||||
|
||||
mkContainer = { image, dependsOn ? [], hostName, port, volumes ? [], environment ? [], homepageOpts, public ? false}:
|
||||
let routerRule = if public then hostRule hostName else localHostRule hostName;
|
||||
in
|
||||
{
|
||||
image = image;
|
||||
autoStart = true;
|
||||
dependsOn = dependsOn;
|
||||
extraOptions = [
|
||||
"-l=traefik.enable=true"
|
||||
"-l=traefik.http.routers.${hostName}.rule=${routerRule}"
|
||||
"-l=traefik.http.services.${hostName}.loadbalancer.server.port=${toString port}"
|
||||
"-l=homepage.group=${homepageOpts.group}"
|
||||
"-l=homepage.name=${homepageOpts.name}"
|
||||
"-l=homepage.icon=${homepageOpts.icon}"
|
||||
"-l=homepage.href=https://${hostName}.${config.domainName}"
|
||||
"-l=homepage.description=${homepageOpts.description}"
|
||||
];
|
||||
volumes = volumes;
|
||||
environment = environment;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user