DevOps Automation using Docker , Jenkins and Git/Github

DevOps Automation using Docker , Jenkins and Git/Github

This project uses DevOps tools for continuous development, continuous integration and continuous deployment.We have to configure Jenkins in such a way that whenever any code change is done and pushed on github then github will trigger it to Jenkins and Jenkins run the jobs on it's own



A step-by step process for the project is described below:

  • First of all we have create a git repository locally and on the GitHub. Git and GitHub. We already have master branch created so we have to create an additional branch so in my case I have created dev1 branch.
No alt text provided for this image


No alt text provided for this image


  • Now we have to create a hook which is present in the folder .git/hooks/. Now in that we have to create a file named post-commit which will automate all the operations after commit has been made so in my case I have added the git push command and the github url and token which will automatically trigger Jenkins whenever there will be a commit made. All the code in post-commit file should be written in bash script format.

NOTE: We don't have to create separate hooks for branches one hooks file will look for both my master as well as dev1 branch.

No alt text provided for this image
No alt text provided for this image


  • Now create a html or txt file and make changes from dev1 branch and add this file and commit changes. As soon as you will commit changes it will automatically get pushed to the origin(remote repository).
No alt text provided for this image
  • Now we have to create jobs in Jenkins, here in my case I have created three jobs in Jenkins:
  1. Job1: My job1 name is Developer. It checks the dev1 branch in the GitHub that is it will keep an eye on the dev1 branch and will report jenkins as soon as there is commit made in the git and starts a docker image (OS) which is the testing environment . It will check the changes in dev1 branch and will trigger Testing job once the testing is successful.
No alt text provided for this image

2. Job2: My job2 name is Production . It keeps an eye on the master branch in the GitHub and start a docker image (OS) . It will check for any changes made in master branch.In this job we are creating a production environment that will be exposed to the clients

No alt text provided for this image

3. Job3: My job3 name is testing . this job is created to merge the two branches (dev1 and master branch) only when the dev1 branch is completely tested then this on successful testing of this job will merge the two branches and will trigger the Production job that is job2 to display the content to the clients.

No alt text provided for this image
No alt text provided for this image
  • A sample is shown below:

This is a basic website (as I am not a Web developer) before doing any changes in any branches.

No alt text provided for this image

As soon as I commit any changes in my txt file locally on git , the changes goes to GitHub causing Jenkins to start, making Developer job to run first then Testing job and if the previous job is successful then finally Production job.

Developer (job) -------------------> Testing(job)--------------------->Production(job)

if successful if successful

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

If all the jobs executes successfully then the website will have some changes such as: (in my case I have written docker github jenkins integration)

No alt text provided for this image

Also, when Developer job, runs if the previous container is running then first it will be destroyed and a new one will start.

No alt text provided for this image

Future Scope : This project can be further extended by integrating some more tools or more automation like kubernetes ,openshift and providing a better infrastructure to the setup that how can it's efficiency be increased.

No alt text provided for this image

Thank you Vimal Daga Sir for giving us a nice mini project on automation.


Ajinkya Khandave

Associate @JP Morgan Chase and Co. | CIB Technology

4 年

Inspiring

要查看或添加评论,请登录

Tushar Saxena的更多文章

  • Dynamic Jenkins

    Dynamic Jenkins

    This article is a simple integration of GitHub, Jenkins, Kubernetes and Docker to automate the process of deploying a…

    2 条评论
  • Configuring CI/CD on Kubernetes with Jenkins and Groovy

    Configuring CI/CD on Kubernetes with Jenkins and Groovy

    This article is a simple integration of GitHub, Jenkins, Kubernetes and Docker to automate the process of deploying a…

    1 条评论
  • DevOps Assembly Line Task 3

    DevOps Assembly Line Task 3

    This article is a simple integration of GitHub, Jenkins, Kubernetes and Docker to automate the process of deploying a…

    6 条评论
  • INTEGRATING PROMETHEUS AND GRAFANA WITH KUBERNETES

    INTEGRATING PROMETHEUS AND GRAFANA WITH KUBERNETES

    Task : Integrate Prometheus and Grafana and perform in following way: Deploy them as pods on top of Kubernetes by…

  • AWS automation using Terraform and Jenkins

    AWS automation using Terraform and Jenkins

    First lets know about the basic terminologies used in this project . What is Cloud Computing? Cloud computing is a term…

    4 条评论
  • ML + DEVOPS = MLOPS

    ML + DEVOPS = MLOPS

    So before starting this article my one question to everyone is why 90% of machine learning models not deployed ? So…

    4 条评论
  • Face Recognition Model

    Face Recognition Model

    Training a model from scratch requires a very large dataset and takes a lot of time to train. The solution to this is…

  • Docker + Git + Github + Jenkins = Automated Project#2

    Docker + Git + Github + Jenkins = Automated Project#2

    This article is based on a integration of great DevOps tools like git , github , jenkins , docker. Integrating all the…

    6 条评论

社区洞察

其他会员也浏览了