diff --git a/.gitignore b/.gitignore index d7b30a7..36e9c94 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ rust-demo-app/target +/.idea/ diff --git a/docker-compose-using-tube-cheese/README.md b/docker-compose-using-tube-cheese/README.md new file mode 100644 index 0000000..5b439d7 --- /dev/null +++ b/docker-compose-using-tube-cheese/README.md @@ -0,0 +1,27 @@ +# Use sozu as reverse-proxy with docker-compose (using tube-cheese) + +First, you have to install [docker-compose](https://docs.docker.com/compose/install/) to execute this demo + +We have to add the domain names to our */etc/hosts* file +``` +127.0.0.1 pikachu.local mewtwo.local nidoqueen.local +``` + +If you want to use Docker Machine, you can too. Just put the right ip into /etc/hosts `docker-machine ip` + +First, we will start the local containers (it takes few minutes): +``` +docker-compose up -d +``` + +Next, deploy the many pokemons containers +``` +docker-compose -f docker-compose.pokemons.yml up -d +``` + +Open browser and try to open these urls to discover the proxying is working. +* [pikachu.local](http://pikachu.local) +* [mewtwo.local](http://mewtwo.local) +* [nidoqueen.local](http://nidoqueen.local) + +Best for now is to open all files and play with it ;-) diff --git a/docker-compose-using-tube-cheese/config/sozu.toml b/docker-compose-using-tube-cheese/config/sozu.toml new file mode 100644 index 0000000..f66885f --- /dev/null +++ b/docker-compose-using-tube-cheese/config/sozu.toml @@ -0,0 +1,19 @@ +command_socket = "/var/run/sozu/socket" +saved_state = "./state.json" +log_level = "debug" +log_target = "stdout" +command_buffer_size = 16384 + +[metrics] +address = "192.168.59.103" +port = 8125 + +[proxies] + +[proxies.HTTP] +address = "0.0.0.0" +proxy_type = "HTTP" +max_connections = 20000 +port = 80 +buffer_size = 16384 +worker_count = 1 \ No newline at end of file diff --git a/docker-compose-using-tube-cheese/config/traefik.toml b/docker-compose-using-tube-cheese/config/traefik.toml new file mode 100644 index 0000000..5d1a3f4 --- /dev/null +++ b/docker-compose-using-tube-cheese/config/traefik.toml @@ -0,0 +1,7 @@ +defaultEntryPoints = ["http"] +[web] + address = ":8080" + +[entryPoints] + [entryPoints.http] + address = ":8081" diff --git a/docker-compose-using-tube-cheese/docker-compose.pokemons.yml b/docker-compose-using-tube-cheese/docker-compose.pokemons.yml new file mode 100644 index 0000000..5d531a5 --- /dev/null +++ b/docker-compose-using-tube-cheese/docker-compose.pokemons.yml @@ -0,0 +1,33 @@ +version: "3" + +services: + + pikachu: + container_name: pikachu + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=25 + - MESSAGE="Pika Pika" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:pikachu.local" + + mewtwo: + container_name: mewtwo + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=150 + - MESSAGE="Mew Mew" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:mewtwo.local" + + nidoqueen: + container_name: nidoqueen + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=31 + - MESSAGE="Nido Nido" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:nidoqueen.local" diff --git a/docker-compose-using-tube-cheese/docker-compose.yml b/docker-compose-using-tube-cheese/docker-compose.yml new file mode 100644 index 0000000..62ee9a8 --- /dev/null +++ b/docker-compose-using-tube-cheese/docker-compose.yml @@ -0,0 +1,48 @@ +version: "3" + +services: + + sozu: + image: geal/sozu + container_name: sozu + command: ["start", "-c", "/etc/sozu/sozu.toml"] + volumes: + - sozu-socket:/var/run/sozu + - ./config/sozu.toml:/etc/sozu/sozu.toml + ports: + - "80:80" + labels: + - "traefik.enable=false" + + sozu-manager: + image: geal/manager + container_name: tube-cheese + command: ["--config", "/etc/sozu/sozu.toml", "--api", "http://traefik:8080/api"] + volumes: + - sozu-socket:/var/run/sozu + - ./config/sozu.toml:/etc/sozu/sozu.toml + depends_on: + - sozu + - traefik + labels: + - "traefik.enable=false" + + traefik: + image: traefik + container_name: traefik + command: --web --docker --docker.domain=local --logLevel=DEBUG --docker.exposedbydefault=true --docker.watch=true + # if you don't want to declare manually entries into /etc/hosts, you can use the awesome xip.io + # command: --web --docker --docker.domain=127.0.0.1.xip.io --logLevel=DEBUG --docker.exposedbydefault=true --docker.watch=true + ports: + - "9090:8080" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./config/traefik.toml:/traefik.toml + labels: + - "traefik.enable=false" + +volumes: + sozu-socket: + + +