Files
sablier/plugins/caddy
Alexis Couvreur be7ace0e05 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-07-08 00:10:39 -04:00
..

Caddy Sablier Plugin

Build the custom Caddy image with Sablier middleware in it

In order to use the custom plugin for Caddy, you need to bundle it with Caddy. Here I'll show you two options with Docker.

By using the provided Dockerfile

docker build https://github.com/acouvreur/sablier.git#v1.8.0-beta.8:plugins/caddy 
  --build-arg=CADDY_VERSION=2.6.4
  -t caddy:2.6.4-with-sablier

Note: You can change main for any other branch (such as beta, or tags v1.8.0-beta.8)

By updating your Caddy Dockerfile

ARG CADDY_VERSION=2.6.4
FROM caddy:${CADDY_VERSION}-builder AS builder

ADD https://github.com/acouvreur/sablier.git#v1.8.0-beta.8 /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

Configuration

You can have the following configuration:

:80 {
	route /my/route {
    sablier [<sablierURL>=http://sablier:10000] {
			[names container1,container2,...]
			[group mygroup]
			[session_duration 30m]
			dynamic {
				[display_name This is my display name]
				[show_details yes|true|on]
				[theme hacker-terminal]
				[refresh_frequency 2s]
			}
			blocking {
				[timeout 1m]
			}
		}
    reverse_proxy myservice:port
  }
}

Exemple with a minimal configuration

Almost all options are optional and you can setup very simple rules to use the server default values.

:80 {
	route /my/route {
    sablier {
			group mygroup
			dynamic
		}
    reverse_proxy myservice:port
  }
}

Running end to end tests

  1. Build local sablier docker build -t caddy:local .
  2. Build local caddy docker build -t acouvreur/sablier:local ../..
  3. Run test cd e2e/docker && bash ./run.sh