mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-25 14:59:16 +01:00
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
113 lines
5.3 KiB
YAML
113 lines
5.3 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.swarm=true
|
|
- --providers.swarm.refreshSeconds=1 # Default is 15s
|
|
- --providers.swarm.allowemptyservices=true
|
|
ports:
|
|
- target: 80
|
|
published: 8080
|
|
protocol: tcp
|
|
mode: host # Won't work in github actions otherwise
|
|
volumes:
|
|
- '/var/run/docker.sock:/var/run/docker.sock'
|
|
- '../../../..:/plugins-local/src/github.com/acouvreur/sablier'
|
|
deploy:
|
|
labels:
|
|
- traefik.http.services.traefik.loadbalancer.server.port=8080
|
|
restart_policy:
|
|
condition: none # Do not restart on setup failure
|
|
|
|
sablier:
|
|
image: acouvreur/sablier:local
|
|
command:
|
|
- start
|
|
- --provider.name=swarm
|
|
- --logging.level=trace
|
|
volumes:
|
|
- '/var/run/docker.sock:/var/run/docker.sock'
|
|
deploy:
|
|
labels:
|
|
- traefik.enable=true
|
|
# Dynamic Middleware
|
|
- traefik.http.middlewares.dynamic.plugin.sablier.names=DOCKER_SWARM_E2E_whoami
|
|
- traefik.http.middlewares.dynamic.plugin.sablier.sablierUrl=http://tasks.sablier:10000
|
|
- traefik.http.middlewares.dynamic.plugin.sablier.sessionDuration=1m
|
|
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.displayName=Dynamic Whoami
|
|
# Blocking Middleware
|
|
- traefik.http.middlewares.blocking.plugin.sablier.names=DOCKER_SWARM_E2E_whoami
|
|
- traefik.http.middlewares.blocking.plugin.sablier.sablierUrl=http://tasks.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_SWARM_E2E_whoami,DOCKER_SWARM_E2E_nginx
|
|
- traefik.http.middlewares.multiple.plugin.sablier.sablierUrl=http://tasks.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_SWARM_E2E_nginx
|
|
- traefik.http.middlewares.healthy.plugin.sablier.sablierUrl=http://tasks.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://tasks.sablier:10000
|
|
- traefik.http.middlewares.group.plugin.sablier.sessionDuration=1m
|
|
- traefik.http.middlewares.group.plugin.sablier.dynamic.displayName=Group E2E
|
|
- traefik.http.services.sablier.loadbalancer.server.port=10000
|
|
|
|
whoami:
|
|
image: acouvreur/whoami:v1.10.2
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "-f", "http://localhost" ]
|
|
interval: 5s
|
|
deploy:
|
|
replicas: 0
|
|
labels:
|
|
- sablier.enable=true
|
|
- sablier.group=E2E
|
|
- traefik.enable=true
|
|
# If you do not use the swarm load balancer, traefik will evict the service from its pool
|
|
# as soon as the service is 0/0. If you do not set that, fallback to dynamic-config.yml file usage.
|
|
- traefik.docker.lbswarm=true
|
|
- traefik.http.routers.whoami-dynamic.middlewares=dynamic@swarm
|
|
- traefik.http.routers.whoami-dynamic.rule=PathPrefix(`/dynamic/whoami`)
|
|
- traefik.http.routers.whoami-dynamic.service=whoami
|
|
- traefik.http.routers.whoami-blocking.middlewares=blocking@swarm
|
|
- traefik.http.routers.whoami-blocking.rule=PathPrefix(`/blocking/whoami`)
|
|
- traefik.http.routers.whoami-blocking.service=whoami
|
|
- traefik.http.routers.whoami-multiple.middlewares=multiple@swarm
|
|
- traefik.http.routers.whoami-multiple.rule=PathPrefix(`/multiple/whoami`)
|
|
- traefik.http.routers.whoami-multiple.service=whoami
|
|
- traefik.http.routers.whoami-group.middlewares=group@swarm
|
|
- traefik.http.routers.whoami-group.rule=PathPrefix(`/group`)
|
|
- traefik.http.routers.whoami-group.service=whoami
|
|
- traefik.http.services.whoami.loadbalancer.server.port=80
|
|
|
|
nginx:
|
|
image: nginx:1.23.1
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost"]
|
|
interval: 5s
|
|
deploy:
|
|
replicas: 0
|
|
labels:
|
|
- sablier.enable=true
|
|
- sablier.group=E2E
|
|
- traefik.enable=true
|
|
# If you do not use the swarm load balancer, traefik will evict the service from its pool
|
|
# as soon as the service is 0/0. If you do not set that, fallback to dynamic-config.yml file usage.
|
|
- traefik.docker.lbswarm=true
|
|
- traefik.http.routers.nginx-multiple.middlewares=multiple@swarm
|
|
- traefik.http.routers.nginx-multiple.rule=PathPrefix(`/multiple/nginx`)
|
|
- traefik.http.routers.nginx-multiple.service=nginx
|
|
- traefik.http.routers.nginx-healthy.middlewares=healthy@swarm
|
|
- traefik.http.routers.nginx-healthy.rule=PathPrefix(`/healthy/nginx`)
|
|
- traefik.http.routers.nginx-healthy.service=nginx
|
|
- traefik.http.services.nginx.loadbalancer.server.port=80
|