Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add shell version client and more readme
- Loading branch information
1 parent
49b9325
commit 18b9ca7
Showing
3 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
# Caddy API gateway demo | ||
Use caddy as microservice API gateway in docker swarm. | ||
|
||
## RUN | ||
## Requirements | ||
* Docker Engine 1.13+ | ||
* docker-compose 1.11.2+ | ||
|
||
## Notice | ||
The image in docker-compose is build by Dockerfile.app and Dockerfile.gateway in this demo. | ||
I've host it in docker hub, so you can use it in next step. | ||
You can also build the image by yourself, then don't forget to change the image name in docker-compose.yml | ||
|
||
## Run Server | ||
Pull images from docker hub: | ||
```bash | ||
docker-compose pull | ||
``` | ||
Run | ||
```bash | ||
docker stack deploy -c docker-compose.yml caddy | ||
``` | ||
|
||
## TRY | ||
visit http://{your-host-ip}:2015 | ||
## Try | ||
Because of caddy's proxy connection reuse feature, you can't test this demo by | ||
visit http://{your-host-ip}:2015 in your browser. | ||
I write a client to send concurrent requests. | ||
If you have go env, | ||
```bash | ||
cd client | ||
go run main.go | ||
``` | ||
Hello, world! I am 72ec231a5eba :) | ||
Hello, world! I am c1a1bc3e79a1 :) | ||
Hello, world! I am 3e4f9f63c1a0 :) | ||
You can also use unix shell version: | ||
```bash | ||
sh test.sh | ||
``` | ||
app will tell you which container it is running in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
for i in $(seq 30) | ||
do curl http://127.0.0.1:2015 & | ||
done | ||
sleep 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters