This is a simple microservices example that uses Ruby + Sinatra to provide a simple Products Service. Docker support is included for running locally or deploying to services such as Cloud66
Note: This isn't production-ready code. The service assumes no Mongo username/password, doesn't force SSL, or enforce security best practices. This is for demonstration and learning purposes only.
Install the required Rubygems:
Set an environment variable to point to the location of your MongoDB instance (e.g. 127.0.0.01 for localhost, or the specific IP/hostname if not localhost)
Running locally using Docker
Use docker-compose to build the service and mongodb containers (takes a few minutes the first time):
Then start the the containers:
Deploying to Cloud 66
Cloud 66 is a Manager Containers as a Service that supports deploying Docker containers onto one or more servers using a bring-your-own-cloud approach.
Read the Cloud 66 blog post for details on deploying this project to your preferred cloud provider.
Interacting with the Products Service
Get a list of products (empty by default):
curl -X GET http://127.0.0.1:4567/products
Add a new product:
curl -X POST http://127.0.0.1:4567/products -F "name=My Product"