From 18b9ca7e705bd32f82beb373cd7ee6a923dc5058 Mon Sep 17 00:00:00 2001 From: "wangrh@99" Date: Thu, 2 Mar 2017 15:57:10 +0800 Subject: [PATCH] add shell version client and more readme --- README.md | 34 ++++++++++++++++++++++++++-------- client/test.sh | 5 +++++ docker-compose.yml | 6 ++---- 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 client/test.sh diff --git a/README.md b/README.md index 2fc066d..76c2486 100644 --- a/README.md +++ b/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. diff --git a/client/test.sh b/client/test.sh new file mode 100644 index 0000000..7f66f6c --- /dev/null +++ b/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 diff --git a/docker-compose.yml b/docker-compose.yml index 4ba8b33..1cfee9f 100644 --- a/docker-compose.yml +++ b/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: