Configure EC2 instance to setup the CI pipeline
To setup Docker, Jenkins and SonarQube (in next section) server, create a t2.large Ubuntu EC2 instance on AWS and use the below startup shell script to install the pre-requisites:
#!/bin/bash
sudo apt update
#Install JDK
sudo apt install openjdk-17-jre -y
#Install Jenkins
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 -y
# Install Docker
sudo apt install docker.io -y
# Grant Jenkins and Ubuntu user permission to access Docker daemon
sudo usermod -aG docker jenkins
sudo usermod -aG docker ubuntu
sudo systemctl restart docker


Create a Security Group and allow the below ports under Inbound rules
Type
Port
Used For
SSH
22
SSH to the instance
TCP
8010
Application port
TCP
8080
Jenkins port
TCP
9000
SonarQube port

After connecting to the EC2 instance verify whether JDK, Docker and Jenkins is properly installed using the following commands:
# Check java version
java --version
# Check Docker version
docker --version
# Check whether Jenkins is running
ps -ef | grep jenkins

Last updated