Skip to content

Instantly share code, notes, and snippets.

@mappingvermont
Last active March 1, 2017 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mappingvermont/9d34ba977b486b5e74588e10f9ada01f to your computer and use it in GitHub Desktop.
Save mappingvermont/9d34ba977b486b5e74588e10f9ada01f to your computer and use it in GitHub Desktop.
Setting up control-tower and a sample microservice

Dev environment setup

On an ubuntu machine or mac, install the following:

  • docker
  • docker compose

Detailed steps done on an ubuntu 16.04 machine

Install docker: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
Install docker compose: https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-16-04

Starting control-tower, the gateway manager

Clone control tower locally: https://github.com/control-tower/control-tower
Rename dev.env.sample to dev.env
Start control tower: ./controlTower.sh develop

Starting node-skeleton

Clone the project: https://github.com/Vizzuality/node-skeleton
Add your internal IP to /etc/hosts with the alias mymachine
Try and start the example microservice: ./nodeSkeleton.sh develop If this fails, edit docker-compose-develop.yml in the node-skeleton repo, replacing mymachine with your internal IP
Then start the microservice with ./nodeSkeleton.sh develop

Testing the microservice and gateway

Make a test request to the control-tower:
curl localhost:9000
Response: {"errors":[{"status":404,"detail":"Endpoint not found"}]}

In the node-skeleton repo, look at app/microservice/register.json to understand what endpoints are being made available. Looks like /api/v1/node-skeleton/hi should expose a route over GET.

Look at docker-compose-develop.yml to find the proper port with which to talk to the microservice directly, in this case looks like 3005. Test this endpoint:
curl localhost:3005/api/v1/node-skeleton/hi
Response: {"hi": "Ra"}

Now try communicating with this service, but through the main gateway. Looking at the register.json file, it looks like the endpoint available in the gateway will be /node-skeleton/hi. Try it through the main gateway:
curl localhost:9000/node-skeleton/hi
Response: {"hi": "Ra"}

Great! We now have a working microservice and gateway deployed locally! Time to develop!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment