commit daab4851edd05cf58ac153e877906d781fa20c2c Author: 1-h Date: Fri Aug 30 15:31:07 2024 +0800 first commit diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..6ad5d7b --- /dev/null +++ b/Caddyfile @@ -0,0 +1,17 @@ +:80 { + route /whoami { + # https://acouvreur.github.io/sablier/#/plugins/caddy?id=configuration + sablier http://sablier:10000 { + group demo + session_duration 5s + dynamic { + display_name My Whoami Service + show_details on + theme shuffle # https://acouvreur.github.io/sablier/#/themes?id=themes + refresh_frequency 1s + } + } + + reverse_proxy whoami:80 + } +} diff --git a/Dockerfile.caddy-with-sablier b/Dockerfile.caddy-with-sablier new file mode 100644 index 0000000..253181e --- /dev/null +++ b/Dockerfile.caddy-with-sablier @@ -0,0 +1,12 @@ +ARG CADDY_VERSION=2 +ARG SABLIER_VERSION=v1.7.0 +FROM caddy:${CADDY_VERSION}-builder AS builder + +ADD https://github.com/acouvreur/sablier.git#${SABLIER_VERSION} /sablier + +RUN xcaddy build \ + --with github.com/acouvreur/sablier/plugins/caddy=/sablier/plugins/caddy + +FROM caddy:${CADDY_VERSION} + +COPY --from=builder /usr/bin/caddy /usr/bin/caddy \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6bb9816 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# sablier-example +``` +docker compose create +docker compose up -d sablier proxy +curl http://localhost:8080/whoami; echo -e "\n等待启动完成"; sleep 3; curl http://localhost:8080/whoami; +``` \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..03aec76 --- /dev/null +++ b/compose.yml @@ -0,0 +1,23 @@ +services: + proxy: + build: + dockerfile: Dockerfile.caddy-with-sablier + ports: + - "8080:80" + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile:ro + + # http://150.230.239.12:8080/whoami + whoami: + image: containous/whoami + labels: + - sablier.enable=true + - sablier.group=demo + + sablier: + image: acouvreur/sablier:1.7.0 + command: + - start + - --provider.name=docker + volumes: + - '/var/run/docker.sock:/var/run/docker.sock'