InsureMe was having trouble managing their software because it was all one big piece.
As they grew bigger, it became even harder to manage.
Whenever a developer makes changes to the code and pushes them to the master branch of the Git repository,
Jenkins should automatically start a deployment process.
Jenkins should:
- Check out the latest code from the master branch.
- Compile and test the code to ensure it works correctly
- Package the application into a container using Docker.
- Deploy the containerized application to a preconfigured test server on AWS
With DevOps Approch I used several devops tools such as
- Git: Managed code changes with version control.
- Jenkins: Automated integration, testing, and deployment processes.
- Docker: Containerized applications for consistency and scalability.
- Ansible: Automated server configuration and infrastructure management.
- AWS: Provided infrastructure for hosting and deploying the application.
Together, these tools streamlined development, testing, and deployment, ensuring efficient management of the InsureMe project.
- Create two EC2 instances on Amazon Web Services (AWS): one called Master and the other called Node.
- These servers will host application and manage its deployment.
- Install Jenkins on the Master server to automate the process of building, testing, and deploying application.
- Set up Jenkins to watch your code repository on GitHub.
- Whenever someone makes changes to the code and pushes them to GitHub, Jenkins automatically kicks off a process to update and deploy application.
- Used Docker to package application and its dependencies into a container, making it easy to deploy and run anywhere.
- After that write a pipeline in Jenkins to build, test, and deploy your application automatically.
- This pipeline runs every time someone makes changes to the code, ensuring that the latest version of your application is always available.
- Whenever someone pushes changes to the code, Jenkins pulls the latest code, builds the application, creates a Docker image, and pushes it to DockerHub (a service for storing Docker images).
- Then, it deploys the updated application to your servers on AWS using Ansible, a tool for automating server configuration.
- With this setup, you can fully automated process for building, testing, and deploying your application.
- Whenever someone make changes to the code, Jenkins takes care of the rest, ensuring that your application is always up-to-date and running smoothly on your servers.
✓ AWS - For creating ec2 machines as servers and deploy the web application.
✓ Git - For version control for tracking changes in the code files
✓ Jenkins - For continuous integration and continuous deployment
✓ Docker - For deploying containerized applications
✓ Ansible - Configuration management tools
Create two ec2 instance
- Master
- Worker
- ami = ubuntu
- instance type = t2.medium
- ports = 22, 8080
Take SSH and Connect to Instance
sudo apt update -y
sudo apt install fontconfig openjdk-17-jre -y
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update -y
sudo apt-get install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Access Jenkins in a web browser using the public IP of your EC2 instance.
1.Maven Integration plugin
2.Docker
3.Docker Commons
4.Docker Pipeline
5.Docker API
6.docker-build-step
As soon as the developer pushes the updated code on the GIT master branch, the Jenkins job should be triggered using a GitHub Webhook and Jenkins job should be triggered In Jenkins Job ->Configuration->choose GitHub hook trigger for GITScm polling
To Create Webhook: go to settings of your github repository In Payload URL: Add yours jenkins url
sudo apt install docker.io -y
sudo usermod -aG docker jenkins
sudo systemctl restart jenkins
Add DockerHub Credentials:
To securely handle DockerHub credentials in your Jenkins pipeline, follow these steps:
Go to "Dashboard" → "Manage Jenkins" → "Manage Credentials."
Click on "System" and then "Global credentials (unrestricted)."
Click on "Add Credentials" on the left side.
Choose "Secret text" as the kind of credentials.
Enter your DockerHub credentials (Username and Password) and give the credentials an ID (e.g., "docker").
Click "OK" to save your DockerHub credentials.
pipeline {
agent any
stages {
stage('Code-Checkout') {
steps {
checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'github-token', url: 'https://github.com/abhipraydhoble/Project-InsureMe.git']])
}
}
stage('Code-Build') {
steps {
sh 'mvn clean package'
}
}
stage('Containerize the application'){
steps {
echo 'Creating Docker image'
sh "docker build -t abhipraydh96/insure:v1 ."
}
}
stage('Docker Push') {
agent any
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
sh 'docker push abhipraydh96/insure:v1'
}
}
}
stage('Code-Deploy') {
steps {
ansiblePlaybook credentialsId: 'ansible', installation: 'ansible', playbook: 'ansible-playbook.yml', vaultTmpPath: ''
}
}
}
}
Build Pipeline:
Final Output: node ip:container port









