This repository contains a demo of how to run multiple services within Cloud Foundry. It will focus on the technical details instead of how to decompose your domain into microservices.
This demo deploys the applications, packaged as Docker images, to a Lattice instance running locally.
DISCLAIMER: This mono-repo may or may not be the best structure for your microservice repository. These services are all in one repository for simplicity of explanation. For more details, see Building Microservices by Sam Newman.
-
service-discovery - A Spring Boot application that uses a Eureka server from Spring Cloud to handle service discovery
-
property-lookup - A Java 8/Spring Boot based service that can look up property data.
-
tax-calculator - A Java 8/Spring Boot based service that queries the property-lookup service and calculates property tax based on the property information.
-
property-lookup-app - A Ruby/Sinatra application that uses the property-lookup service to display property information.
The Docker images are built using a Gradle plugin and can be created by running ./gradlew build buildDocker
.
Prerequisites for building Docker images are:
- Boot2docker installed locally
- A DockerHub login
Before running the buildDocker command in a terminal window, you must have the 3 boot2docker env variables
set in that window (see docker up
for details). You also need to be logged in to DockerHub via docker login
.
See the Lattice walkthrough for details on how to use Lattice.
You can use the bin/deploy-to-lattice.sh <DockerHub tag>
script to deploy Docker containers pushed to DockerHub to your
local Lattice installation.
You can query the service-discovery service for information about the registered services using curl:
curl http://service-discovery.192.168.11.11.xip.io/eureka/apps
Please note that it takes ~30 seconds for a new service instance to be registered with the service-discovery service.