TABLE OF CONTENTProblem StatementPrerequisiteImportant steps usedGithub cloneGitHub ConfigurationDeployment configurationTest Job ConfigurationProblem Statement
Create a Dockerfile to create a Jenkins container image. Then automate provisioning of the environment to deploy the webpages using Jenkins.
Docker must first be installed. If you are using another operating system, then use their package and service manager.
We created a Dockerfile with a base image of centos 7, and then created a Jenkins container file.
Important steps
Jenkins requires Java to be installed on the backend. To download the official Jenkins repository from the internet, Wget must be installed. The gpg key is then added to allow yum repo authorization. Jenkins is installed once the yum repo has been configured with the correct gpg key. We need to install the service utility in order to start Jenkins service.6 It must be exposed to port 8080 for connection to Jenkins server7. Finally, the script will start Jenkins service using the service utility and put the container into sleep mode so it won’t get stopped.

Docker file to create Jenkins Image
Github clone
The following command can be used to create a Dockerfile:docker build-t image_name version workspace_namewhere workspace_name = absolute paths where the Dockerfile is.
Now, we will launch the Jenkins server using the image above.
Now, using this image, the Jenkins container has been launched and five jobs have been created
This job will clone the GitHub repository on Jenkins server. The code will then be used to deploy the website.
Image-1: It shows the repo URL where the code will fetch for deployment.

Image-2: It shows the @ (to-ssh plugin), which is the server on the given commands will be executed. The command copies the github_clone repository from the container to a document root on the web server. This will allow it to be hosted.

GitHub Configuration
We create a container, mount the repo to the document root within the container, and then this job will deploy code to the container using docker in Redhat’s system. Because Jenkins is running on the container and we need to build this job on a remote server, the ssh plugin can be used to deploy it.

Configuration for deployment
If the code is written in another language, we can use yum to install the appropriate interpreter (e.g., if PHP is being used, then install PHP-CLI).
This job will examine the status code of web pages as provided by the browser. If bugs are found, a notification with the error message embedded will be sent to developer.

Test Job Configuration
The email plugin allows you to configure the email notification. This can be done as follows:

This job is to monitor the deployment job. If the container crashes or fails, it will automatically create another container for you.

About CloudThat
CloudThat offers end-to-end support for all AWS services. CloudThat is a pioneer in cloud computing consulting. We are AWS (Amazon Web Services), Advanced Consulting Partner, as well as a Training Partner. We are dedicated to building a strong cloud computing ecosystem by sharing knowledge about technological intricacies within this space. Learn more about CloudThat’s Expert Advisory and Consulting.