mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
docs: add example for the quickstart
This commit is contained in:
96
README.md
96
README.md
@@ -11,12 +11,14 @@ Which allows you to start your containers on demand and shut them down automatic
|
|||||||

|

|
||||||
|
|
||||||
- [Sablier](#sablier)
|
- [Sablier](#sablier)
|
||||||
- [Quick start](#quick-start)
|
- [Quick start with Traefik](#quick-start-with-traefik)
|
||||||
|
- [Reverse proxies integration plugins](#reverse-proxies-integration-plugins)
|
||||||
|
- [Traefik Middleware Plugin](#traefik-middleware-plugin)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [Configuration File](#configuration-file)
|
- [Configuration File](#configuration-file)
|
||||||
- [Environment Variables](#environment-variables)
|
- [Environment Variables](#environment-variables)
|
||||||
- [Arguments](#arguments)
|
- [Arguments](#arguments)
|
||||||
- [Install Sablier](#install-sablier)
|
- [Install Sablier on its own](#install-sablier-on-its-own)
|
||||||
- [Use the Docker image](#use-the-docker-image)
|
- [Use the Docker image](#use-the-docker-image)
|
||||||
- [Use the binary distribution](#use-the-binary-distribution)
|
- [Use the binary distribution](#use-the-binary-distribution)
|
||||||
- [Compile your binary from the sources](#compile-your-binary-from-the-sources)
|
- [Compile your binary from the sources](#compile-your-binary-from-the-sources)
|
||||||
@@ -25,54 +27,58 @@ Which allows you to start your containers on demand and shut them down automatic
|
|||||||
- [Creating your own loading theme](#creating-your-own-loading-theme)
|
- [Creating your own loading theme](#creating-your-own-loading-theme)
|
||||||
- [Blocking the loading until the session is ready](#blocking-the-loading-until-the-session-is-ready)
|
- [Blocking the loading until the session is ready](#blocking-the-loading-until-the-session-is-ready)
|
||||||
- [Saving the state to a file](#saving-the-state-to-a-file)
|
- [Saving the state to a file](#saving-the-state-to-a-file)
|
||||||
- [Reverse proxies integration plugins](#reverse-proxies-integration-plugins)
|
|
||||||
- [Traefik Middleware Plugin](#traefik-middleware-plugin)
|
|
||||||
- [Glossary](#glossary)
|
- [Glossary](#glossary)
|
||||||
- [Credits](#credits)
|
- [Credits](#credits)
|
||||||
|
|
||||||
## Quick start
|
## Quick start with Traefik
|
||||||
|
|
||||||
|
You will see how to use Sablier with Traefik in order to start your container automatically when reaching it by its route.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create and stop nginx container
|
git clone https://github.com/acouvreur/sablier
|
||||||
docker run -d --name nginx nginx
|
cd sablier
|
||||||
docker stop nginx
|
docker-compose up -d
|
||||||
|
docker-compose stop whoami
|
||||||
|
|
||||||
# Create and stop whoami container
|
# Now you go to http://localhost:8080/whoami/dynamic with your browser
|
||||||
docker run -d --name whoami containous/whoami:v1.5.0
|
# Or you can call the blocking URL, this will wait until whoami is started
|
||||||
docker stop whoami
|
curl http://localhost:8080/whoami/blocking
|
||||||
|
|
||||||
# Start Sablier with the docker provider
|
Hostname: 1d034329b651
|
||||||
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 10000:10000 ghcr.io/acouvreur/sablier:latest start --provider.name=docker
|
IP: 127.0.0.1
|
||||||
|
IP: 172.18.0.2
|
||||||
# Start the containers, the request will hang until both containers are up and running
|
RemoteAddr: 172.18.0.4:33052
|
||||||
curl 'http://localhost:10000/api/strategies/blocking?names=nginx&names=whoami&session_duration=1m'
|
GET /whoami/blocking HTTP/1.1
|
||||||
{
|
Host: localhost:8080
|
||||||
"session": {
|
User-Agent: curl/7.68.0
|
||||||
"instances": [
|
Accept: */*
|
||||||
{
|
Accept-Encoding: gzip
|
||||||
"instance": {
|
X-Forwarded-For: 172.18.0.1
|
||||||
"name": "nginx",
|
X-Forwarded-Host: localhost:8080
|
||||||
"currentReplicas": 1,
|
X-Forwarded-Port: 8080
|
||||||
"desiredReplicas": 1,
|
X-Forwarded-Proto: http
|
||||||
"status": "ready"
|
X-Forwarded-Server: 1aea141808c5
|
||||||
},
|
X-Real-Ip: 172.18.0.1
|
||||||
"error": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"instance": {
|
|
||||||
"name": "nginx",
|
|
||||||
"currentReplicas": 1,
|
|
||||||
"desiredReplicas": 1,
|
|
||||||
"status": "ready"
|
|
||||||
},
|
|
||||||
"error": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status":"ready"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Reverse proxies integration plugins
|
||||||
|
|
||||||
|
The reverse proxy integrations is probably what you're most interested about.
|
||||||
|
|
||||||
|
It leverage the API calls to Sablier to your reverse proxy middleware to wake up your instances on demand.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Traefik Middleware Plugin
|
||||||
|
|
||||||
|
See [Traefik Middleware Plugin](https://github.com/acouvreur/sablier/tree/main/plugins/traefik/README.md)
|
||||||
|
|
||||||
|
- [Traefik Middleware Plugin with Docker classic](https://github.com/acouvreur/sablier/tree/main/plugins/traefik/README.md#traefik-with-docker-classic)
|
||||||
|
- [Traefik Middleware Plugin with Docker Swarm](https://github.com/acouvreur/sablier/tree/main/plugins/traefik/README.md#traefik-with-docker-swarm)
|
||||||
|
- [Traefik Middleware Plugin with Kubernetes](https://github.com/acouvreur/sablier/tree/main/plugins/traefik/README.md#traefik-with-kubernetes)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
There are three different ways to define configuration options in Sablier:
|
There are three different ways to define configuration options in Sablier:
|
||||||
@@ -179,9 +185,9 @@ Becomes
|
|||||||
sablier start --strategy.dynamic.custom-themes-path /my/path
|
sablier start --strategy.dynamic.custom-themes-path /my/path
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install Sablier
|
## Install Sablier on its own
|
||||||
|
|
||||||
You can install Traefik with the following flavors:
|
You can install Sablier with the following flavors:
|
||||||
|
|
||||||
- Use the Docker image
|
- Use the Docker image
|
||||||
- Use the binary distribution
|
- Use the binary distribution
|
||||||
@@ -279,11 +285,7 @@ If the file doesn't exist it will be created, and it will be syned upon exit.
|
|||||||
|
|
||||||
Loaded instances that expired during the restart won't be changed though, they will simply be ignored.
|
Loaded instances that expired during the restart won't be changed though, they will simply be ignored.
|
||||||
|
|
||||||
## Reverse proxies integration plugins
|
|
||||||
|
|
||||||
### Traefik Middleware Plugin
|
|
||||||
|
|
||||||
See [Traefik Middleware Plugin](https://github.com/acouvreur/sablier/tree/main/plugins/traefik/README.md)
|
|
||||||
|
|
||||||
## Glossary
|
## Glossary
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
version: "3.9"
|
version: "3.7"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
traefik:
|
traefik:
|
||||||
image: traefik:2.9.1
|
image: traefik:2.9.1
|
||||||
command:
|
command:
|
||||||
|
- --experimental.plugins.sablier.moduleName=github.com/acouvreur/sablier
|
||||||
|
- --experimental.plugins.sablier.version=v1.1.0
|
||||||
- --entryPoints.http.address=:80
|
- --entryPoints.http.address=:80
|
||||||
- --providers.docker=true
|
- --providers.docker=true
|
||||||
- --providers.file.filename=/etc/traefik/dynamic-config.yml
|
- --providers.file.filename=/etc/traefik/dynamic-config.yml
|
||||||
- --experimental.plugins.sablier.moduleName=github.com/acouvreur/sablier
|
|
||||||
- --experimental.plugins.sablier.version=v1.0.0-beta.2
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -16,19 +16,21 @@ services:
|
|||||||
- './dynamic-config.yml:/etc/traefik/dynamic-config.yml'
|
- './dynamic-config.yml:/etc/traefik/dynamic-config.yml'
|
||||||
|
|
||||||
sablier:
|
sablier:
|
||||||
image: ghcr.io/acouvreur/sablier:local
|
image: acouvreur/sablier:1.1.0
|
||||||
command:
|
|
||||||
- start
|
|
||||||
- --provider.name=docker
|
|
||||||
volumes:
|
volumes:
|
||||||
- '/var/run/docker.sock:/var/run/docker.sock'
|
- '/var/run/docker.sock:/var/run/docker.sock'
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
# Dynamic Middleware
|
# Dynamic Middleware
|
||||||
- traefik.http.middlewares.dynamic.plugin.sablier.name=sablier_whoami_1
|
- traefik.http.middlewares.dynamic.plugin.sablier.names=sablier-whoami-1
|
||||||
- traefik.http.middlewares.dynamic.plugin.sablier.serviceUrl=http://sablier:10000
|
- traefik.http.middlewares.dynamic.plugin.sablier.sablierUrl=http://sablier:10000
|
||||||
- traefik.http.middlewares.dynamic.plugin.sablier.timeout=1m
|
- traefik.http.middlewares.dynamic.plugin.sablier.sessionDuration=1m
|
||||||
- traefik.http.middlewares.dynamic.plugin.sablier.displayname=Dynamic Whoami
|
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.theme=hacker-terminal
|
||||||
|
# Blocking Middleware
|
||||||
|
- traefik.http.middlewares.blocking.plugin.sablier.names=sablier-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
|
||||||
|
|
||||||
whoami:
|
whoami:
|
||||||
image: containous/whoami:v1.5.0
|
image: containous/whoami:v1.5.0
|
||||||
@@ -36,5 +38,5 @@ services:
|
|||||||
# The route doesn't exist anymore. Use dynamic-config.yml file instead.
|
# The route doesn't exist anymore. Use dynamic-config.yml file instead.
|
||||||
# labels:
|
# labels:
|
||||||
# - traefik.enable
|
# - traefik.enable
|
||||||
# - traefik.http.routers.whoami-dynamic.rule=PathPrefix(`/dynamic/whoami`)
|
# - traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)
|
||||||
# - traefik.http.routers.whoami-dynamic.middlewares=dynamic@docker
|
# - traefik.http.routers.whoami.middlewares=dynamic@docker
|
||||||
BIN
docs/img/demo.gif
Normal file
BIN
docs/img/demo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
BIN
docs/img/reverse-proxy-integration.png
Normal file
BIN
docs/img/reverse-proxy-integration.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 227 KiB |
23
dynamic-config.yml
Normal file
23
dynamic-config.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
http:
|
||||||
|
services:
|
||||||
|
whoami:
|
||||||
|
loadBalancer:
|
||||||
|
servers:
|
||||||
|
- url: "http://whoami:80"
|
||||||
|
|
||||||
|
routers:
|
||||||
|
whoami-dynamic:
|
||||||
|
rule: PathPrefix(`/whoami/dynamic`)
|
||||||
|
entryPoints:
|
||||||
|
- "http"
|
||||||
|
middlewares:
|
||||||
|
- dynamic@docker
|
||||||
|
service: "whoami"
|
||||||
|
|
||||||
|
whoami-blocking:
|
||||||
|
rule: PathPrefix(`/whoami/blocking`)
|
||||||
|
entryPoints:
|
||||||
|
- "http"
|
||||||
|
middlewares:
|
||||||
|
- blocking@docker
|
||||||
|
service: "whoami"
|
||||||
Reference in New Issue
Block a user