Web deployment by integrating Github, Jenkins and Docker

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 install 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.

For creating this setup we need a linux os with docker engine running on the top of it.

Let us start step by step.

In this step we need to create container image that’s has Jenkins installed using Dockerfile.

So here I am using centos as image to create container image that’s has Jenkins installed.

Build the image using the command

docker build -t jenkins:v1 .

In this step we have to launch a container from jenkins:v1 image and also it should automatically starts Jenkins service in the container.

Launch the container using the command

docker run -it privileged -v /:/host -p 8081:8080 — name jenkinsos jenkins:v1

We need to setup jenkins:

Now we need to create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins .

Let’s craete job1

Job1 : Pull the Github repo automatically when some developers push repo to Github.

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 ).

Here in my case I have a php webpage. So I am using a webserver:v1 image which has apache webserver, php software already installed.

Job3 : Test your app if it is working or not

Job4 : if app is not working , then send email to developer with error messages.

For sending the mail I am using a python code which is their in jenkins image. So if app will be not working then the code will get executed and it will notify the developer.

Here is the output of my build pipeline.

This is the mail I get when there was an error in the code and the site was not working.

We need to create one extra job for monitoring.

Job 5: This job is for monitor the container where app is running If it fails due to any reason then this job will automatically start the container again.

Here is the console output of Job 5

Here is the screenshot of two containers running with jenkins and webserver.

Thank You !!

--

--

--

I'm passionate learner diving into the concepts of computing 💻

Love podcasts or audiobooks? Learn on the go with our new app.

The brain’s instruction fetch cycle

There Are Not Enough Slots Available In The System Mpi

There Are Not Enough Slots Available In The System Mpi

How to add security camera to stealth game in Unity

Status cell: UX tip X Apps script

Best projects to start coding

Apache Spark and BigQuery with AWS Sagemaker Studio

How to Run a Data Science Project in a Docker Container

What is “Memory Leak” in programming?

water leaking from pipe

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditya Raj

Aditya Raj

I'm passionate learner diving into the concepts of computing 💻

More from Medium

Solving Jenkins “stderr=Host key verification failed” problem when all else fails

Deployment flow (Github -> Jenkins -> Remote -> AWS ECR)

Docker: Containers For absolute Beginners

Hello World from Docker

Introduction to Docker