bkono / microdc-example

Example of docker-compose, consul in docker-compose, go-micro, and more.
0 stars 4 forks source link

Greeter

This repo exists to answer a few questions I'm frequently asked regarding usage of multi-step builds, docker-compose, consul, and go-micro. Configuration is as follows:

This example uses the api, parts of srv, and cli components from the official micro greeter example. For details on each component, please review the original.

Contents

Run the suite

docker-compose up microapi

That's it. Seriously. The microapi block is configured with dependencies on all other components to provide a simple entry point.

Testing from the host

In the docker-compose file, microapi is bound to 8090 on the host. This allows for convenient curl based testing.

❯ curl "localhost:8090/greeter/say/hello?name=John"
{"message":"Hello John"}

Log samples for the above request:

microapi_1  | 172.20.0.1 - - [21/Sep/2017:17:28:33 +0000] "GET /greeter/say/hello?name=John HTTP/1.1" 200 24 "" "curl/7.54.0"

api_1       | 2017/09/21 17:28:33 Received Say.Hello API request

srv_1       | 2017/09/21 17:28:33 Received Say.Hello request

vip_1       | 2017/09/21 17:28:23 Received VIP.CheckName request
vip_1       | 2017/09/21 17:28:23 is vip check false

consul is also launched with a ui, and bound to the host at 8500. Navigate to http://localhost:8500/ui to view the current running services.