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

Create 3 jobs to automate the integration and deployment process
creating demo repositories using Git

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

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.

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