A microserice sample using spring boot, docker, traefik, ELK...
Let's say you want to develop some microservices. To avoid creating too much git repositories, you decide to put all of them in a single git repository.
As CI-CD tool, you decide to use Jenkins with its feature: pipeline-as-code.
Now come the bad news: so far jenkins does not support several Jenkinsfiles per repository.
This project is an attempt to bypass this current limitation.
This idea is to have a single Jenkinsfile at the root of the repository.
When a given microservice is updated, this Jenkinsfile will perform a diff to identify which microservice is impacted by the changeset and will trigger only the build for those microservices.
At the end of the build, a dedicated tag (lastbuild_<branchname>
) is pushed to the repository so that it would be possible to
calculate the changeset with the previous successful build.
for each project
mvn clean package docker:build
All microservices mcr* are behind a reverse proxy called Traefik.
Start the compose file:
docker-scripts/docker-compose up
Or better, use swarm:
docker swarm init
docker stack deploy -c ./docker-scripts/docker-compose.yml mcr
Test it :
run the following commands to create the keycloak user and db:
createuser -c 20 -D -E -l -S -R -i -h localhost -p 5432 -U postgres -W ukeycloak -P
createdb -h localhost -p 5432 -U postgres -W -O ukeycloak -E utf-8 keycloak
In order to activate logging in an ELK stack, you need to deploy docker-compose-logging.yml
in a docker stack.
Follow the steps below:
Run this command:
docker swarm init
Run this command:
docker config create logstash.conf ./etc/logstash.conf
Run this command:
docker network create -d overlay log
Run this command:
docker stack deploy -c ./docker-scripts/docker-compose-logging.yml log
A new stack named log
is created.
Run this command:
docker stack rm log
The stack named log
is removed.