Continuous Integration/Continuous Deployment (CI/CD) is an important aspect of modern software development. Jenkins, GitHub, and Docker are some of the most commonly used tools for CI/CD. In this blog post, we will walk you through the steps to integrate Jenkins with GitHub and use Docker Compose for deploying the application.
Step-by-Step Guide:
Launch an AWS EC2 instance(jenkins-node)
Login to your AWS EC2 instance and install Java Development Kit (JDK) followed by jenkins :
sudo apt update sudo apt install openjdk-11-jre java -version openjdk version
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
✨✨✨✨✨✨✨✨Jenkins is active and running✨✨✨✨✨✨✨✨✨
By default jenkins runs on port 8080 so we need to expose port 8080 , but how?🙄Ok so click on our instance and navigate to security of our instance:
Ok now click on security groups and Edit inbound rules and click on add rule
Select custom TCP and port range as 8080 and source as my IP
6. Now we can access jenkins on our web browser by our IP followed by port 8080 as follow:
The passwork required to access Jenkins can be accessed as follow:
Click on install suggested plugins
It will ask for user name and set password and jenkins is all set :
✨✨✨✨✨✨✨✨✨Ok Now lets start the real work✨✨✨✨✨✨✨✨
create a new item as follow:
Enter the discription and select as a git hub project and enter the URL of the project
Source code management select Git and enter the git URL
Select branch as master
Now time for github integration with Jenkins via SSH so navigate into our console and type ssh-keygen
Inside .ssh directory public and private keys are stored,for github to connect we need public key so copy that as shown:
Now navigate to your github settings inside SSh keys and add new key
and add title and paste the public key as follow:
Now access is provided let's add credentials
select domain as (Global credentials)
kind = SSH user name and private-key
id = github jenkins
description = This is for GitHub and jenkins integration
username = ubuntu
enter private key add new and copy and paste from the .ssh directory inside the id_rsa file
and save
GitHub integration is done
Now click on build now and navigate to the console output:
inside our console navigate to workspace directory our app is ready
Go to the security group of our instance edit inbound rule select port 8000 and give access to every one by selecting ipv4 protocol
Now time to configure our node app so go to execute shell
save and click on build now
That's it! 🎉🎉✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨You have successfully created a Jenkins project for your Node-Todo-CICD app