You are on page 1of 14

Submitted by:

Name: Aqsa Sarfraz


Reg No: Fa20-bse-034
Date: 26-10-2023
Subject: Topics in Computer Science
Submitted to:
Dr Farhan Adil
Final Task of Semester
QNO1: Docker Containerization
• Create a simple web application (e.g., a "Hello World" Flask application or any sample website
template).

• Write a Dockerfile to containerize the web application.

DockerFile
• Build the Docker image and push it to Docker Hub.

DockerHub
QNO2: Jenkins CI/CD Pipeline
• Install Jenkins on your local machine.

• Set up a Jenkins job that pulls the source code of the web application from a version control system
(e.g., GitHub).
• Set up a Git Repository: You can create a Git repository for your project, or you can use an existing
project.
Using my existing Github repository, I have added docker file and Jenkins file in repository. We will
create Jenkins job in Pipeline.
a. Build

b. Test

c. Deploy
• The pipeline should be able to roll back to the previous version in case of a failed deployment.

• The pipeline should be able to send email notifications to the team in case of a failed deployment.

Build Result
Sends Email when Builds Fail
Build Success
QNO3: AWS EC2 Instance
I have used Microsoft azure service instead of AWS.
Create an AWS EC2 instance (Ubuntu Server) and configure security groups to allow traffic on port 80.
Configure the necessary security groups, key pairs, and network settings.
• Install Docker on the EC2 instance.

• Pull the Docker image of the web application from Docker Hub and run it on the EC2 instance.
QNO4: Pipeline Automation
• Modify the Jenkins job to trigger the pipeline automatically whenever changes are pushed to the version
control system.
We will add Jenkinsfile in GitHub repository
Add link of git repository in Source Code Managment, after creating freestyle Jenkins job.
Build Success
• Implement deployment steps in the Jenkins job to SSH into the AWS EC2 instance and update the
running Docker container.
Generated key and paste it to authorized_key file.
GitHub Repository
https://github.com/aqsasarfraz1/testproject1.git

Explanation Of CI/CD Pipeline working in this task.

Triggering:
The CI/CD pipeline is triggered automatically whenever there is a change in the source code repository or
based on a scheduled interval.

Agent Allocation:
The pipeline begins by allocating an agent (Jenkins worker node) to execute the pipeline stages.

Environment Setup:
Environment variables (DOCKER_IMAGE and CONTAINER_NAME) are defined to streamline
configuration across pipeline stages.

Build Stage:
Purpose: Build the Docker image for the application.

Steps:
The pipeline enters the 'Build' stage.
A Docker image is built using the docker build command, tagging it with the Jenkins build number for
versioning.
Deploy Stage:

Purpose: Deploy the newly built Docker image.

Steps:
The pipeline proceeds to the 'Deploy' stage.
The existing Docker container is stopped and removed to ensure a clean deployment environment.
A new Docker container is run in detached mode (-d), with port mapping, using the latest image.

Post-Build Actions:
Purpose: Handle actions after the pipeline completes.

Steps:
In case of a deployment failure, an email notification is sent to a specified email address (fa20-bse-
034@cuiatk.edu.pk).
The email contains information about the failure and a link to the Jenkins console output for detailed
analysis.

Outcome:
• If the deployment is successful, the latest version of the application is running in a Docker
container.
• If the deployment fails, an email notification is sent, allowing the team to promptly address and
troubleshoot the issue.

You might also like