- Consulting
- Training
- Partners
- About Us
x
TABLE OF CONTENT |
Problem Statement |
Prerequisite |
Important steps used |
Github clone |
GitHub Configuration |
Deployment configuration |
Test Job Configuration |
Creating a Dockerfile to create Jenkins container image and then automate provisioning the environment to deploy the webpages with the help of Jenkins.
Docker must be installed and in running state, CENTOS system is employed in this tutorial. (If you are using other operating systems then use their respective package and service manager.)
We have created a Dockerfile using a base image as centos 7 and then created a Jenkins container image.
Jenkins requires java to be installed in the backend,
2. Wget is installed to download Jenkins official repository from the web,
3. Then the gpg-key is added for the yum repo to get authorized,
4. We install Jenkins as the yum repo is configured with proper gpg-key,
5. To start Jenkins service we have to install service utility,
6. For the connection to Jenkins server, it must be exposed on 8080 port,
7. Finally, we have a script that starts Jenkins service (with the help of the service utility) and puts the container in sleep mode so that it will not get stopped.
Docker file to create Jenkins Image
We can create the docker file by using the following command:
docker build -t image_name: version workspace_name
where workspace_name = absolute path where the Dockerfile is present.
We will now launch the Jenkins server by using the above image.
Now using this image, we have launched the Jenkins container and created five jobs
This job will clone from the GitHub repository on the Jenkins server and hence this code will be used for the deployment of the website.
Image-1: It depicts the repo URL from where the code will be fetched for the deployment.
Image-1
Image-2: It depicts the <username> @<ip> (to ssh plugin) of the server on which the given commands are to be executed (ignore the warnings if any). The command is to copy the github_clone repo from the container to the document root of the web server (so that it will be hosted).
Image-2
Deploy:
We run a container and mount the repo in the document root inside the container and then this job will deploy the code into the container by using docker in the Redhat system. ssh plugin is used to deploy it on a remote host because Jenkins is running on the container, therefore, we require to build this job on a remote host.
Image-3
If the code that is used is written in some other language then we can install its respective interpreter using the yum install <interpretor package name> (e.g if PHP is used then install PHP-CLI).
Test:
This job will check the status code of the web pages given by the browser and if some bugs show up then a notification will be sent to the developer with the error message embedded in it.
Image-4
Using the email plugin the email notification is configured, which can be configured as shown:
Image-5
Monitor:
This job is to monitor the deployment job, So, if the container crashes or fails it will automatically create a new container for the use.
Image-6
CloudThat provides end-to-end support with all the AWS services. As a pioneer in the Cloud Computing consulting realm, we are AWS (Amazon Web Services) Advanced Consulting Partner, and Training partner. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Read more about CloudThat’s Consulting and Expert Advisory.
Voiced by Amazon Polly |
CloudThat is a leading provider of cloud training and consulting services, empowering individuals and organizations to leverage the full potential of cloud computing. With a commitment to delivering cutting-edge expertise, CloudThat equips professionals with the skills needed to thrive in the digital era.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Click to Comment