arion/examples/traefik/arion-compose.nix

65 lines
1.6 KiB
Nix
Raw Permalink Normal View History

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";
2023-07-19 11:12:42 +02:00
config.networks = {
traefik-custom = {
name = "traefik-custom";
ipam = {
config = [{
subnet = "172.32.0.0/16";
gateway = "172.32.0.1";
}];
};
};
};
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" ];
2023-07-19 11:12:42 +02:00
networks = [ "traefik-custom" ];
2021-01-21 23:43:03 +01:00
};
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.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";
2023-07-19 11:12:42 +02:00
"traefik.http.services.nix-docs.loadBalancer.server.port" = "8000";
};
service.networks = {
traefik-custom = {
ipv4_address = "172.32.0.5";
};
2021-01-21 23:07:52 +01:00
};
};
};
}