diff --git a/examples/traefik/arion-compose.nix b/examples/traefik/arion-compose.nix index 03cacb6..b6c6f7d 100644 --- a/examples/traefik/arion-compose.nix +++ b/examples/traefik/arion-compose.nix @@ -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 = { - traefik.service = { - image = "traefik:v2.4"; - container_name = "traefik"; - command = [ + traefik = { + image.command = [ + "${pkgs.traefik}/bin/traefik" "--api.insecure=true" "--providers.docker=true" "--providers.docker.exposedbydefault=false" "--entrypoints.web.address=:80" ]; - ports = [ "80:80" "8080:8080" ]; - volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ]; + service = { + container_name = "traefik"; + stop_signal = "SIGINT"; + ports = [ "80:80" "8080:8080" ]; + volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ]; + }; }; - whoami.service = { - image = "traefik/whoami"; - container_name = "simple-service"; - labels = { + 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 = { "traefik.enable" = "true"; - "traefik.http.routers.whoami.rule" = "Host(`whoami.localhost`)"; - "traefik.http.routers.whoami.entrypoints" = "web"; + "traefik.http.routers.nix-docs.rule" = "Host(`nix-docs.localhost`)"; + "traefik.http.routers.nix-docs.entrypoints" = "web"; }; }; };