examples/traefik: Make pure

This commit is contained in:
Robert Hensing 2021-01-21 23:43:03 +01:00
parent ee2f71327d
commit 32b00781b4

View file

@ -1,26 +1,47 @@
{ pkgs, ... }: { /*
An example of
- traefik HTTP reverse proxy
- minimal images
- routing via docker labels
Run `arion up -d` and open http://nix-docs.localhost/
*/
{ lib, pkgs, ... }: {
config.services = { config.services = {
traefik.service = { traefik = {
image = "traefik:v2.4"; image.command = [
container_name = "traefik"; "${pkgs.traefik}/bin/traefik"
command = [
"--api.insecure=true" "--api.insecure=true"
"--providers.docker=true" "--providers.docker=true"
"--providers.docker.exposedbydefault=false" "--providers.docker.exposedbydefault=false"
"--entrypoints.web.address=:80" "--entrypoints.web.address=:80"
]; ];
ports = [ "80:80" "8080:8080" ]; service = {
volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ]; container_name = "traefik";
stop_signal = "SIGINT";
ports = [ "80:80" "8080:8080" ];
volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ];
};
}; };
whoami.service = { nix-docs = {
image = "traefik/whoami"; image.command = ["${pkgs.writeScript "entrypoint" ''
container_name = "simple-service"; #!${pkgs.bash}/bin/bash
labels = { cd ${pkgs.nix.doc}/share/doc/nix/manual
${pkgs.python3}/bin/python -m http.server
''}"];
service.container_name = "simple-service";
service.ports = [
"8000:8000" # host:container
];
service.stop_signal = "SIGINT";
service.labels = {
"traefik.enable" = "true"; "traefik.enable" = "true";
"traefik.http.routers.whoami.rule" = "Host(`whoami.localhost`)"; "traefik.http.routers.nix-docs.rule" = "Host(`nix-docs.localhost`)";
"traefik.http.routers.whoami.entrypoints" = "web"; "traefik.http.routers.nix-docs.entrypoints" = "web";
}; };
}; };
}; };