This Github repository features a small microservices sample, using the following libraries:
- Spring Boot: together with Jetty as application runner within the Docker containers.
- Docker and Docker compose: Docker images are generated and composed in order to run this example.
- Spring Cloud: abstract Netflix OSS tooling with the Spring Cloud suite.
- Netflix OSS libraries:
- Zuul proxy: Used to unify all access to services.
- Eureka Discovery: Used to keep track of alive service instances.
- Ribbon: Used to load balance on the client (or invoker) side.
- Hystrix: Used to monitor failure and short-circuit in case it's needed.
- Turbine: Used to monitor service status on a distributed fashion.
- Angular2: Used to create a simple front application that consumes the exposed REST services. This application includes lazy loading and ahead of time (AOT) compilation.
- Webpack: Used to package the Angular2 application and deliver the distributable objects into the microservice.
On top of the mentioned libraries, this sample provides two services:
- Authors-service: service which contains a very simple authors repository.
- Books-service: service which contains a very simple books repository.
- Releases-service: service which contains a very simple releases repository.
- Front-service: service which contains a very simple Angular2 front application.
The books service uses the authors service in order to retrieve authors data, serving as a sample of service communication within Docker containers.
The front service publishes a frontend application which consumes and manipulates the data exposed by the services.
I've ran this test with the following Ubuntu, Docker and Docker compose versions:
- Ubuntu: 16.04
- Docker API: 1.25
- Docker Version: 1.13.0
- NPM version: 3.10.10
- Node version: 6.9.4
- Webpack: 2.2.0
- Angular 2: 2.4.6
You ought to follow these steps in order to run this sample on your local machine.
- Compile the images and get them into your local Docker registry:
On the parent project folder, execute a Maven package command:
sudo mvn clean install -P docker
- Run the generated images using Docker compose:
After you've compiled the projects, you should be able to see the images on your local registry:
sudo docker images
In order to execute the example, run the docker-compose.yml file using the following command at the parent project folder:
sudo docker-compose up
Optional: You may want to redirect the console output generated into a file. In this case, use the following command instead:
sudo docker-compose up > yourfilename.log