54 lines
1.5 KiB
Nix
54 lines
1.5 KiB
Nix
config:
|
|
let
|
|
havenisms = "havenisms.com";
|
|
blazestar = "blazestar.net";
|
|
hostRule = host: domain: "Host(`${host}.${domain}`)";
|
|
hostRuleHavenisms = host: hostRule host havenisms;
|
|
localNet = "192.168.0.0/16";
|
|
dockerNet = "10.88.0.0/16";
|
|
localNetRule = "(ClientIP(`${localNet}`) || ClientIP(`${dockerNet}`))";
|
|
localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}";
|
|
localHostRuleHavenisms = host: localHostRule host havenisms;
|
|
in
|
|
{
|
|
inherit
|
|
hostRule
|
|
localHostRule
|
|
hostRuleHavenisms
|
|
localHostRuleHavenisms
|
|
havenisms
|
|
blazestar;
|
|
|
|
|
|
mkContainer = {
|
|
image,
|
|
hostName,
|
|
port,
|
|
homepageOpts,
|
|
dependsOn ? [],
|
|
domain ? havenisms,
|
|
volumes ? [],
|
|
environment ? [],
|
|
public ? false
|
|
}:
|
|
let routerRule = if public then hostRule hostName domain else localHostRule hostName domain;
|
|
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}.${domain}"
|
|
"-l=homepage.description=${homepageOpts.description}"
|
|
];
|
|
volumes = volumes;
|
|
environment = environment;
|
|
};
|
|
}
|