To demonstrate the power of docker compose and Infrastructure as code (IaC) I put together the following functional example. I must also give credit to Godfrey Sisimogang for his input into the initial process flow – thank you my mate.
The Eco-systems is made up of the following layers
- Git clone
- API to communicate with the database
- Fizz buzz generator
- Angular Web Application to GET and display the data
- Source code for application and config
- Created with http://draw.io
To spin up the entire echo-system run ./compose.sh
In my case my local laptop runs Windows 10 and the docker magic runs in a virtual machine using Oracle VM VirtualBox. The virtual machine runs Ubuntu Server this I felt was as close to the bare metal servers most corporate companys will be running.
Create a new virtual machine with Virtual Box
Boot into the OS & Install Docker CE
Clone these scripts from github to the local windows host
- Its possible to clone directly to the Ubuntu VM but thats up to you
Create a directory compose-demo
- With nano create the compose.sh shell script and paste in the values from github and mark the script as executable
sudo nano compose.sh
Repeat the above for the start.sh shell script
sudo nano docker-compose.yml
right click to paste from your clip board
Create the angular-web directory
Copy or create
into the directory ‘angular-web’
Edit the index.html file to use the IP of the VM and target the API port
Create the flyway-git-clone directory
Copy or create the Dockerfile into this directory
Change back up a directory to ‘compose-demo’, your folder should look like this now
- Run compose.sh
NOTE WHAT THE SCRIPT WILL DO:
a. The removal of containers
b. The removal of volumes (if found)
This will then run though the overview layers above, once complete you can browse the angular container which will call the API and display the fizz buzz data.
Exit code 0 means the container completed its life without any issues.
- Display all the containers, note that the compose containers take their names from the name in the YML file.
sudo docker ps --all
- You can now startup just the required containers with start.sh
- This will only start the database, API and Angular Web containers
You can then call the API directly, example http://10.0.0.108:3000/fizzbuzz_data
The IP of your container will depend on your Host VM and DHCP server.
You can then also call the angular application, example http://10.0.0.108:8080/