Docker+Jenkins: DevopsAssembly Line
This is my solution to task 2 of DevopsAssembly Line Training under Vimal Daga Sir where we were given to configure Jenkins on Docker using Dockerfile and then create Job Chain to perform the following task using build pipeline.
The main motive of this task is to automate the stuff and use the concepts of containerization to run things in small memory and size. By the use of docker, we can launch any OS or software within a few mins and that also customized accdoring to our needs.
According to me, this task can be considered as the real-world scenario use case where we will be developing a coding website and we need different compilers we can use this concept to as such projects.
1. Create a container image that’s has Jenkins installed using Dockerfile. When we launch this image, it should automatically start the Jenkins service in the container.
4. Job1: Pull the Github repo automatically when some developers push the repo to Github.
***Set Github Repo in Jenkins and build trigger to run JOB 2 after the stable build***
*** Set the Hook to trigger the Job 1 as we commit the code. ***
Hook: post-commit , loc : /.git/hooks
5. Job2: By looking at the code or program file, Jenkins should automatically start the respective language interpreter install image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).
*** Check the file extension and run the container according to it ***
6. Job3: Test your app if it is working or not.
*** Checking if the server is running or not and send email to the developer ***
7. Job4: if the app is not working, then send an email to the developer.
*** Python Script to send mail ***
## Warning: Make sure to enable less secure apps in your google account settings.
As we build JOB1 another Job also runs and here the JOB4 will run only on the fail of JOB3 so it's blue and not running.
8. Job5: If the container where the app is running. fails due to any reason then this job should automatically start the container again.