This project is a Node.js-based web application that uses the Express framework for building a RESTful API. The application is designed to interact with a MongoDB database for data storage and Redis for session management, and includes an end-to-end CI/CD pipeline using Jenkins and Argo CD for continuous integration and deployment.
- Go to AWS console
- Go to instances
- Launch Instance
You need to use t2.large because we're going to use docker as an agent for our pipeline which uses more CPU & RAM.
Pre-Requisites:
- Java (JDK)
- Postman (For using APIs)
- Docker Desktop
- minikube (Running on local device in docker desktop)
Install Java
sudo apt update
sudo apt install openjdk-17-jre
java -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
Note: By default, You will not be able to access Jenkins
in the external world due to the inbound traffic restriction by AWS. Open port 8080 in the inbound traffic rules as show below.
-
EC2 > Instances > Click on
-
In the bottom tabs -> Click on Security
-
Security groups
-
Add inbound traffic.
Type Port range Source Custom TCP 8080 Anywhere-IPv4
http://ec2-instance-public-ip-address
:8080 [You can get the ec2-instance-public-ip-address from your AWS EC2 console page]
After you login to Jenkins,
- Run the command to copy the Jenkins Admin Password -
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Enter the Administrator password
- Click on Install suggested plugins
- Wait for the Jenkins to Install suggested plugins
- Create First Admin User or Skip the step [If you want to use this Jenkins instance for future use-cases as well, better to create admin user]
- Jenkins Installation is Successful. You can now starting using the Jenkins
- Log in to Jenkins.
- Go to Manage Jenkins > Manage Plugins.
- In the Available tab, search for "Docker Pipeline".
- Select the plugin and click the Install button.
- Restart Jenkins after the plugin is installed.(To restart jenkins just add
/restart
at the url example:http://ec2-instance-public-ip-address:8080/restart
) - Wait for the Jenkins to be restarted.
Run the below command to Install Docker
sudo apt update
sudo apt install docker.io
sudo su -
usermod -aG docker jenkins
usermod -aG docker ubuntu
systemctl restart docker
Once you are done with the above steps, it is better to restart Jenkins.
http://<ec2-instance-public-ip>:8080/restart
The docker agent configuration is now successful.
-
Create a job
-
create pipeline name, select Pipeline and Click on
OK
-
Go to pipeline
-
Select pipeline script from SCM, select SCM as github
-
Enter repository URL
https://github.com/AmanGupta677/node-docker.git
-
edit branch specifier to
*/main
-
Click on
Apply
andSave
- Log in to Jenkins.
- Go to Manage Jenkins > Credentials.
- Click on System
- Click on Global Credentials then Add credentials
- Select
Kind
as username and password and put your docker hub username and password and on theID
section putdocker-cred
- And create
- click on Add credentials
- Select
Kind
as Secret Text and put youGithub
Token in secret text box and putID
asgithub
- and create
- Go to Dashboard, click on you pipeline
- click on
BUILD NOW
Now you pipeline is created for Continuous Integration