GitHub, Jenkins, and Docker Integration

Megha Bansal
Analytics Vidhya
Published in
3 min readAug 28, 2020
  • The industry is moving towards automating everything. This article in about integrating our GitHub repository with Jenkins and using containers ( Docker) to deploy web pages ( Using httpd image)
  • We have to create a master branch and a developer branch in a new repository in GitHub.
  • Then we have to create 3 jobs in Jenkins:

JOB 1:

If Developer pushes to developer branch then Jenkins will fetch from developer branch and deploy the website on the developer-docker environment ( Testing environment)

JOB 2:

If Developer pushes to master branch then Jenkins will fetch from the master branch and deploy on the master-docker environment ( Production environment) and use ngrok ( tunnel ) to connect to the world.

JOB 3:

This is the job managed by the Quality Assurance team. If the site is correct and meets the requirements, this job would be executed. It will go to GitHub, merge the developer branch with the master branch, and trigger JOB 2.

PREREQUISITES:

  • Linux
  • Git Bash
  • GitHub
  • Docker — CE
  • Jenkins
  • Browser

STEPS:

1) A repository is created locally with 2 branches- Master and Developer and the website content has been added.

2) Jenkins has been installed in our Redhat8 system. We have to start its service.

Jenkins provides us with a UI to use it easily which can be accessed from the browser using the IP address of our RedHat system.

3) JOB 1:

This job will download and copy the file from GitHhub in redhat to the specified folder , and will launch the docker OS.

Code written for launching docker OS:

4) JOB3:

The QAT(Quality Assurance Team) will check the code and if it doesn’t pass the requirements then this will not be merged with the master branch. Else, it will be merged and trigger job2

5) JOB2:

If Developer pushes to master branch then Jenkins will fetch from the master branch and deploy on the Production environment. ( Both the testing and production environment is in different docker container)

Code written for launching docker env:

Finally, we create a tunnel using ./ngrok and visit our deployed web page

For any queries, connect with me on Linkedln.

Published By

Originally published at https://www.linkedin.com.

--

--

Megha Bansal
Analytics Vidhya

DevOps Engineer at JFrog | Linux | Python | Git | Docker | Kubernetes | AWS | Terraform | CI-CD