52 lines
1.4 KiB
Nix
52 lines
1.4 KiB
Nix
# Static websites
|
|
{ lib, config, ... }:
|
|
let
|
|
inherit (import ./lib.nix config)
|
|
terakoda
|
|
havenisms
|
|
blazestar
|
|
;
|
|
mkStaticSite =
|
|
{
|
|
host,
|
|
dir ? "public",
|
|
}:
|
|
let
|
|
cleanHost = lib.strings.stringAsChars (c: if c == "." then "-" else c) host;
|
|
in
|
|
{
|
|
"${cleanHost}-static" = {
|
|
image = "nginx:alpine";
|
|
autoStart = true;
|
|
volumes = [
|
|
"/tank/web/${host}/${dir}:/usr/share/nginx/html:ro"
|
|
];
|
|
labels = {
|
|
"traefik.enable" = "true";
|
|
"traefik.http.routers.${cleanHost}.rule" = "Host(`${host}`) || Host(`www.${host}`)";
|
|
"traefik.http.routers.${cleanHost}.middlewares" = "${cleanHost}-add-www@docker";
|
|
"traefik.http.services.${cleanHost}.loadbalancer.server.port" = "80";
|
|
"traefik.http.middlewares.${cleanHost}-add-www.redirectregex.regex" = "^https://${host}/(.*)";
|
|
"traefik.http.middlewares.${cleanHost}-add-www.redirectregex.replacement" =
|
|
"https://www.${host}/\${1}";
|
|
"traefik.http.middlewares.${cleanHost}-add-www.redirectregex.permanent" = "true";
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
virtualisation.oci-containers.containers =
|
|
mkStaticSite {
|
|
host = terakoda;
|
|
dir = "deployed";
|
|
}
|
|
// mkStaticSite {
|
|
host = blazestar;
|
|
dir = "deployed";
|
|
}
|
|
// mkStaticSite {
|
|
host = havenisms;
|
|
dir = "public";
|
|
};
|
|
}
|