Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rust-demo-app/target
/.idea/
27 changes: 27 additions & 0 deletions docker-compose-using-tube-cheese/README.md
Original file line number Diff line number Diff line change
@@ -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 ;-)
19 changes: 19 additions & 0 deletions docker-compose-using-tube-cheese/config/sozu.toml
Original file line number Diff line number Diff line change
@@ -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]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table is now call applications


[proxies.HTTP]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration now use a Application table.

address = "0.0.0.0"
proxy_type = "HTTP"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will add this in a protocol part. ([http] table)

max_connections = 20000
port = 80
buffer_size = 16384
worker_count = 1
7 changes: 7 additions & 0 deletions docker-compose-using-tube-cheese/config/traefik.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defaultEntryPoints = ["http"]
[web]
address = ":8080"

[entryPoints]
[entryPoints.http]
address = ":8081"
33 changes: 33 additions & 0 deletions docker-compose-using-tube-cheese/docker-compose.pokemons.yml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions docker-compose-using-tube-cheese/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3"

services:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that can be good to add a custom bridge network and avoid to use the default bridge.


sozu:
image: geal/sozu

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use this image instead: clevercloud/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: