We are going to launch jenkins over docker container that auto detect the code and launch the respective docker container and launch the respective webapp.
What we are going to Do:
1. Create container image that’s has Jenkins installed using dockerfile
2. When we launch this image, it should automatically starts Jenkins service in the container.
3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins
4. Job1 : Pull the Github repo automatically when some developers push repo to Github.
5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).
6. Job3 : Test your app if it is working or not.
7. Job4 : if app is not working , then send email to developer with error messages.
8. Create One extra job job5 for monitor : If container where app is running. fails due to any reson then this job should automatically start the container again.
First we have to launch jenkins over Docker, that requires jenkins image.We create image by Dockerfile.
docker build -t jenkins:2 .docker run -it --privileged -p 7777:8080 -v /:/host --name jen1 jenkins:2
After launching jenkins over docker ,the main game starts here.
In job1 jenkins should pull the Github repo automatically when some developers push repo to Github.
First we have to provide our github repo link , so that jenkins auto pull the repo and copy it to local repo.
After job 1 completion , job 2 will be trigger automatically.
It will first detect the language of code and it will launch the respective docker container to host the webapp.
After the stable build of job2 , job 3 will be triggered automatically.
It checks the webapp that it is working properly or not.If webapp is working properly then the job will be stable ,if not then it will be unstable build.
If the webapp is not working properly then job4 will be triggered automatically,that send the mail to developer that webapp is not working properly.
job5 is for to to monitor the container where the code is running, if the contailer fails due to any reason it will automatically launch it.
Now we have successfully integrate Jenkins ,Docker,and GitHub to launch webapp.