Launch an Web-server using Devops Tools and merging dev branch code with master branch code.

Prakash Singh Rajpurohit
5 min readJul 8, 2020

--

In this article you will see how we can integrate Jenkins, Git GitHub and Docker which makes developer and operational team automatic.

To start with article first we understand the little background of Git, GitHub, Jenkins, Docker

Jenkins :

Jenkins is one of the most powerful tool in DevOps world. Jenkins can do continuous development and continuous deployment automatically this makes Jenkins very special. Jenkins power comes from plugins.

GitHub:

GitHub is a system which provide centralized data sharing for remote world. GitHub works on centralized version control system (CVCS). GitHub require Network connectivity. GitHub have graphical user interface.

Git:

Git is a system which provide local data sharing. Git works on decentralized version control system (DVCS). Git don’t require network connectivity when it work locally. If you have network connectivity in your local system you can pull (download) or push (upload) your file from GitHub.Git have command line interface.

Docker:

Docker is a containerization tool. Using Docker we can launch the entire environment for our application server just in 1 second. Docker run in a isolation world so it is very secure to use for application server.

So for practical I am using RHEL -8 OS and windows OS. Using virtualization I installed RHEL — 8 on top of windows OS. In linux OS our Jenkins and docker is running. We will launch the application in docker container. Application server container is running where I am going to upload a developer code for client and my windows OS act as a client to access the webserver.

So let start with practical part, In real world developer write a code for web-application server and then he share the code on GitHub. Now Operational team pull the code, run the code in testing server. If code is running perfectly on testing server then they deploy code on production server. Meanwhile developer is adding more feature in same code and when it is done developer again share the code on Github and operational team run that code in testing server. If code run perfectly on testing server now operational team merge this code with main and then finally they deploy on production server.

So we gonna do the same practical. Let see step by step.

I used httpd image which I pull from docker hub using this command.

docker pull httpd

To launch production server container I used this command

docker run –dit –p 8081:80 –v /var/lib/Jenkins/workspace/Productiondeploy:/usr/local/apache2/htdocs/ — name masterserver httpd

To launch Testing server container I used this command

docker run –dit –p 8082:80 –v /var/lib/Jenkins/workspace/Productiondeploy/:/usr/local/apache2/htdocs/ — name Testing_deploy httpd

Agenda :

  1. JOB 1: If Developer push to master branch then Jenkins will fetch from master and deploy on master-docker environment.
  2. JOB 2: If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.both dev-docker and master-docker environment are on different docker containers.
  3. JOB 3: Manually the QA team will check (test) for the website running in dev-docker environment.
  4. Job 4 : If dev-docker environment it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2.
Complete Workflow of Task

I had written same code in master and dev branch, you can see production server and testing server showing same output.

Code which developer wrote.

Testing Server.
Production Server.

Production server and Testing server shows same output.

Step 1

Job 1:

This job will pull the repository from GitHub and then launch a production server container in RHEL-8.

Job1

Job1 Output:

Job1 Ouput.

Step 2

Job 2 :

job 2 run when developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.

Job2

Job 2 Output:

So you can see developer done some editing in code and it running perfectly on testing server. Now testing job will run check is this testing server working or not.

Job2 Output.

Step 3

Job 3:

In this job QA (Quality Assurance) team will check (test) for the website running in dev-docker environment (testing server).

Job3

As we see in job2 we got the desired output so now testing team will pass the code to merge with production.

Step 4

Job 4:

In this job jenkins wiil go to GitHub and do the merge of master and dev branch code. As soon as master branch updated automatically job1 is going to run because we are using poll scm. Remember there is a chaining between all the jobs that’s why the complete process is automatic.

Job4 part1
Job4 part2
Job4 part3

As soon as master branch get update job1 is going to run automatically.

Job1 ran again and we got these output, which is same as testing server which we had seen.

Production Server.

You can watch the complete practical of this task:

Complete Task Video.

Thank-you for reading.

If this article is helpful, it would be appreciable if you could give 1 clap for it.

--

--

Prakash Singh Rajpurohit
Prakash Singh Rajpurohit

Written by Prakash Singh Rajpurohit

Cloud Stack Developer. Working on Machine Learning, DevOps, Cloud and Big Data.

No responses yet