Skip to content

Commit

Permalink
add shell version client and more readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hyacinthus committed Mar 2, 2017
1 parent 49b9325 commit 18b9ca7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
34 changes: 26 additions & 8 deletions README.md
@@ -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.
5 changes: 5 additions & 0 deletions client/test.sh
@@ -0,0 +1,5 @@
#!/bin/bash
for i in $(seq 30)
do curl http://127.0.0.1:2015 &
done
sleep 1
6 changes: 2 additions & 4 deletions docker-compose.yml
@@ -1,13 +1,11 @@
version: '3'
services:
app:
image: caddydemo-app
ports:
- 12345:12345
image: muninn/caddy-microservice:app
deploy:
replicas: 3
gateway:
image: caddydemo-gateway
image: muninn/caddy-microservice:gateway
ports:
- 2015:2015
depends_on:
Expand Down

0 comments on commit 18b9ca7

Please sign in to comment.