/virtual-vehicles-docker

Repository for files related to containerizing Virtual-Vehicles project, using Docker. See blog post below for project details.

Primary LanguageShellApache License 2.0Apache-2.0

Continuous Integration and Delivery of Microservices

Continuous Integration and Delivery of Microservices-based REST API with RestExpress, Java EE, and MongoDB, using Jenkins CI, Docker Machine, and Docker Compose.

PROJECT CODE UPDATED 11-09-2016 to v4.3.0

Introduction

In the below series of posts, we learned how to use Jenkins CI, Maven, Docker, Docker Compose, and Docker Machine to take a set of Java-based microservices from source control on GitHub, to a fully tested set of integrated Docker containers running within an Oracle VirtualBox VM. We performed integration tests, using a scripted set of synthetic transactions, to make sure the microservices were functioning as expected, within their containers.

ELK Stack 3D Diagram

Reference Blog Posts

Build Test Environment Project

# check for latest versions of required apps
docker -v && docker-compose -v && \
docker-machine -v && VBoxManage --version

# pull this GitHub project
git clone https://github.com/garystafford/virtual-vehicles-docker.git && \
cd virtual-vehicles-docker

# clean up any previous machine failures
docker-machine stop test || echo "nothing to stop" && \
docker-machine rm test   || echo "nothing to remove"

# use docker-machine to create and configure 'test' environment
docker-machine --debug create --driver virtualbox test
eval "$(docker-machine env test)"

# pull build artifacts from virtual-vehicles-demo project
# build (4) Dockerfiles and docker-compose.yml from templates
sh pull_and_build.sh

# use docker-compose to pull and build new images and containers
# this will take up to 20 minutes or more to pull images
docker-compose -p test up -d

# list machines, images, and containers
# check all containers are running
docker-machine ls && \
docker images && \
docker ps -a

# wait for containers to fully start before tests fire up
sleep 20

# add local dns name to hosts file for demo (mac-friendly)
sudo -- sh -c -e "echo '$(docker-machine ip test)   api.virtual-vehicles.com' >> /etc/hosts";

# test the services
sh tests_color.sh api.virtual-vehicles.com

# alternate, test the services using IP address:
# sh tests_color.sh $(docker-machine ip test)

# delete all images and containers
docker rmi -f $(docker images -a -q) && \
docker rm -f $(docker ps -a -q)

# alternate, complete tear down: stop and remove 'test' environment when complete
docker-machine stop test && \
docker-machine rm test
eval "$(docker-machine env -u)"

# other useful commands
# clean up orphaned volumes
docker volume rm $(docker volume ls -qf dangling=true)

# clean up orphaned networks
docker network rm $(docker network ls -q)

# delete all project images, but not base images
docker rmi -f $(docker images | grep 'test_' | awk '{print $3}')

# delete all <none> images
docker rmi -f $(docker images | grep '^<none>' | awk '{print $3}')

Test Results

Integration Tests

Browse the Project

Environment Architecture

ELK Ports