Files
sablier/plugins/traefik/e2e/docker/docker-compose.yml
Alexis Couvreur c6f0628411 perf(providers): retrieve state on start instead of assuming starting (#350)
When an instance does not exist yet and needs to be started, its status is not assumed to be starting anymore.

Instead, the statue will be retrieved from the provider. This changes one thing, it's that you may be able to start and access your services instantly because they'll be instantly seen as ready.

With this change, you might want to make sure that your containers have a proper healthcheck used to determine when the application is able to process incoming requests.

* refactor: add interface guards

* refactor(providers): remove instance.State as a return value from Stop and Start

* test(e2e): add healthcheck on nginx container

Because now the container check is so fast, we need to add a delay on which the container is considered started and healthy to have a proper waiting page.

* fix(tests): using acouvreur/whoami:v1.10.2 instead of containous/whoami:v1.5.0

This image simply retrieve the curl binary from curlimages/curl:8.8.0 to be able to add proper docker healthcheck commands.

Once this is merged with traefik/whoami, I'll update back to the original image.

See https://github.com/traefik/whoami/issues/33
2024-10-01 17:30:14 -07:00

82 lines
3.7 KiB
YAML

version: "3.7"
services:
traefik:
image: traefik:v3.0.4
command:
- --experimental.localPlugins.sablier.moduleName=github.com/acouvreur/sablier
- --entryPoints.http.address=:80
- --providers.docker=true
- --providers.file.filename=/etc/traefik/dynamic-config.yml
ports:
- "8080:80"
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '../../../..:/plugins-local/src/github.com/acouvreur/sablier'
- './dynamic-config.yml:/etc/traefik/dynamic-config.yml'
restart: "no"
sablier:
image: acouvreur/sablier:local
command:
- start
- --provider.name=docker
- --logging.level=trace
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
labels:
- traefik.enable=true
# Dynamic Middleware
- traefik.http.middlewares.dynamic.plugin.sablier.names=docker_classic_e2e-whoami-1
- traefik.http.middlewares.dynamic.plugin.sablier.sablierUrl=http://sablier:10000
- traefik.http.middlewares.dynamic.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.DisplayName=Dynamic Whoami
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.theme=hacker-terminal
# Blocking Middleware
- traefik.http.middlewares.blocking.plugin.sablier.names=docker_classic_e2e-whoami-1
- traefik.http.middlewares.blocking.plugin.sablier.sablierUrl=http://sablier:10000
- traefik.http.middlewares.blocking.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.blocking.plugin.sablier.blocking.timeout=30s
# Multiple Dynamic Middleware
- traefik.http.middlewares.multiple.plugin.sablier.names=docker_classic_e2e-whoami-1,docker_classic_e2e-nginx-1
- traefik.http.middlewares.multiple.plugin.sablier.sablierUrl=http://sablier:10000
- traefik.http.middlewares.multiple.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.multiple.plugin.sablier.dynamic.displayName=Multiple Whoami
# Healthy Middleware
- traefik.http.middlewares.healthy.plugin.sablier.names=docker_classic_e2e-nginx-1
- traefik.http.middlewares.healthy.plugin.sablier.sablierUrl=http://sablier:10000
- traefik.http.middlewares.healthy.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.healthy.plugin.sablier.dynamic.displayName=Healthy Nginx
# Group Middleware
- traefik.http.middlewares.group.plugin.sablier.group=E2E
- traefik.http.middlewares.group.plugin.sablier.sablierUrl=http://sablier:10000
- traefik.http.middlewares.group.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.group.plugin.sablier.dynamic.displayName=Group E2E
whoami:
image: acouvreur/whoami:v1.10.2
# Cannot use labels because as soon as the container is stopped, the labels are not treated by Traefik
# The route doesn't exist anymore. Use dynamic-config.yml file instead.
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost" ]
interval: 5s
labels:
- sablier.enable=true
- sablier.group=E2E
# - traefik.enable
# - traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)
# - traefik.http.routers.whoami.middlewares=ondemand
nginx:
image: nginx:1.27.0
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 5s
# Cannot use labels because as soon as the container is stopped, the labels are not treated by Traefik
# The route doesn't exist anymore. Use dynamic-config.yml file instead.
labels:
- sablier.enable=true
- sablier.group=E2E
# - traefik.enable
# - traefik.http.routers.nginx.rule=PathPrefix(`/nginx`)
# - traefik.http.routers.nginx.middlewares=ondemand