Setup separate testing and production environment using jenkins- docker-github.

#TASK-1

#JOB-1

If Developer push to “dev” branch then Jenkins will fetch from “dev” and deploy on the “dev-docker” environment.

#JOB-2

If Developer push to “master” branch then Jenkins will fetch from “master” and deploy on the master-docker” environment.
both “dev-docker” and “master-docker” environments are on different docker containers.

#JOB-3

Manually the QA team will check (test) for the website running in the “dev-docker” environment. If it is running fine then Jenkins will merge the “dev” branch to “master” branch and trigger #job2

First of all install git which is the Decentralised version control system (DVCS).

Make a local git repository name as “devops_task1” repository also known as (workspace+version)

Now initiate the git in the workspace by “git init “ command and make an HTML file for the website.

Create a GitHub repository ( centralized version control system) where we can upload our website content.

Now add remote origin then add and last push it to GitHub using the master branch. we can also create a dev branch for developer using “git checkout -b dev” command

Now we create #job 1 In this job if developer push the code to dev branch then Jenkins will fetch from dev and deploy on dev docker environment

Set the build triggers Poll SCM

Execute Shell code

sudo cp -v -r -f * /dev

if sudo docker ps | grep testos

then

echo “already launch”

else

sudo docker run -dit -p 8082:80 -v /dev:/usr/local/apache2/htdocs/ — name testos httpd

fi

1st job is created.

Now job2, In this job developer push to master branch then Jenkins will fetch from master and deploy on the master-docker environment (production environment).

Execute Shell code

sudo cp -v -r -f * /prod

if sudo docker ps | grep prodos

then

echo “already launch”

else

sudo docker run -dit -p 8085:80 -v /dev:/usr/local/apache2/htdocs/ — name prodos httpd

fi

After completion of #job 2 now we can create #job 3

In this job QA team will manually test the website running fine or not in the testing environment.

If the website running fine then #job 3 will merge the dev branch to master branch and trigger the #job 2.

All the jobs are created

Now as soon as a developer commits to dev branch, job1 will runs. This will first update the Github and then copy the changed code and host it in docker for testing.

Manually check the website in testing environment.

If the job 2 run successfully we can see our website

After QA team check the website manually, if it is running well then job 3 will run and dev branch merge with master branch. Job 3 build the job 2 after merge successfully.

after completion of job 2, we can see our website is updated.

Finally, let us create a tunnel so that our client can see the website. To create a tunnel we will use ngrok.

This is the updated website. Our client can see this from the anywhere world.

Github link :- https://github.com/atuljha0036/Devops-task-1.git

THANKS FOR READING….