2021-01-21 23:43:03 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
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, ... }: {
|
2022-05-31 23:53:03 +02:00
|
|
|
config.project.name = "traefik";
|
2021-01-21 23:07:52 +01:00
|
|
|
config.services = {
|
2021-01-21 23:43:03 +01:00
|
|
|
traefik = {
|
|
|
|
image.command = [
|
|
|
|
"${pkgs.traefik}/bin/traefik"
|
2021-01-21 23:07:52 +01:00
|
|
|
"--api.insecure=true"
|
|
|
|
"--providers.docker=true"
|
|
|
|
"--providers.docker.exposedbydefault=false"
|
|
|
|
"--entrypoints.web.address=:80"
|
|
|
|
];
|
2021-01-21 23:43:03 +01:00
|
|
|
service = {
|
|
|
|
container_name = "traefik";
|
|
|
|
stop_signal = "SIGINT";
|
|
|
|
ports = [ "80:80" "8080:8080" ];
|
|
|
|
volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ];
|
|
|
|
};
|
2021-01-21 23:07:52 +01:00
|
|
|
};
|
|
|
|
|
2021-01-21 23:43:03 +01:00
|
|
|
nix-docs = {
|
|
|
|
image.command = ["${pkgs.writeScript "entrypoint" ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
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 = {
|
2021-01-21 23:07:52 +01:00
|
|
|
"traefik.enable" = "true";
|
2021-01-21 23:43:03 +01:00
|
|
|
"traefik.http.routers.nix-docs.rule" = "Host(`nix-docs.localhost`)";
|
|
|
|
"traefik.http.routers.nix-docs.entrypoints" = "web";
|
2021-01-21 23:07:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|