30 lines
1.1 KiB
Nix
30 lines
1.1 KiB
Nix
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;
|
|
};
|
|
} |