Setting up a testing & production environment using docker and automating it using Jenkins.

Ankit Prakash
4 min readJul 13, 2020

Create 3 jobs to automate the integration and deployment process

creating demo repositories using Git

Here we created a git repository and created a sample HTML file for testing the setup, and uploaded it in the git hub using the Git Push command.

we have Also, created a copy of the file in a Git Branch namely Dev1 for the development and testing.

Start the Jenkins services

we know that Jenkins works on the port 8080 we made a public tunnel on port 8080 using the ngrok application

Now we need a webserver to launch the sample application we made. here we use the Apache HTTPD server using Docker httpd image

Here we need 2 containers, one for testing the application and other for production on which the clients connect. The testing container is running on the port 8082 and the production container is running on the port 8081.

we need to run this in a public IP so that automation can be done using Jenkins as well as clients can connect. For this, we again make a Public tunnel on port 8081 using the same ngrok application.

login into the Jenkins

Job 1: if the Developer push to Master Branch then Jenkins will fetch from master and deploy on prodOS container, for this you have to go to the configure of Job1 and follow the same as shown.

we will use 2 Triggers one to check to the Remote repository (GitHub) for which we use Triggers builds remotely and the other is for a local repository (Git) for which we use GitHub hook trigger for GITScm polling.

And in Build, we copy the downloaded files in the prod_activity directory in the Linux system

Add hooks in the local Git Repository, which will automatically push the committed file and trigger the Build Trigger by creating a bash file called post-commit

Remote trigger, we have to add webhooks in the GitHub Repository, it’s use is, when any file in the GitHub is changed it pings the Jenkins to download these files, for this, we have to go to settings and then web-hooks
If we go ahead and build/Run the job you will see this page

Job 2: if the Developer push to dev1 branch then Jenkins will fetch from dev1 and deploy on the testOS container, for this you have to go to the configure of Job1 and follow the same as shown.

Job 3: now the OAT will check the test application in the test environment and if it passes the test then Jenkins will merge the dev1 branch to the master branch and trigger Job 1.

we have to do is follow the 2 steps show below:-

1.give the credentials

2.go to the git publisher and enter the shown details, it will automatically merge the files.

Now if we go and Build/Run the job 3 will see this modified page which is made by merging the contents of both the master and branch of the repository.

This dev1 code is deployed in a production environment where the client can access it.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ankit Prakash
Ankit Prakash

No responses yet

Write a response