DevSecOps CICD Java Tomcat Project: Part-1
A complete tutorial for AWS Git, Terraform, Tomcat, Jenkins, SonarQube, Container, Docker
Introduction
Prerequisite:
Install git & clone the Repo
sudo apt install git -y git clone https://github.com/manikcloud/simplilearn-projects.gitcd simplilearn-projects/
How to Create EC2 instance via Terraform:
Open AWS CloudShell
Install Terraform
#!/bin/bash
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform
sudo terraform --version
Run Main.tf & create the infrastructure
terraform init
terraform plan
terraform apply --auto-approve
Terraform Automation: To create AWS infra and install Java 8 Jenkins on Ubuntu 20.04 VM
Terraform Automation: To create AWS infra and install Java 11, Latest Jenkins on Ubuntu 22.04 LTS
Install Java 11 & Jenkins Manually: For Ubuntu 22.04 LTS
#!/bin/bash
sudo apt update && sudo apt upgrade -y
sudo apt install default-jdk -y
sudo java -version
sudo mkdir -p /usr/share/keyrings
sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
sudo 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 update -y
sudo apt install jenkins -y
sudo systemctl start jenkins --no-pager -l
sudo systemctl enable --now jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Install Java 8 & Jenkins Manually: For Ubuntu 20.04
sudo apt update && upgradesudo apt install -y python3.8sudo apt-get updatesudo apt-get install -y openjdk-8-jresudo apt-get install -y jenkinssudo apt-get install -y docker docker.iosudo chmod 777 /var/run/docker.socksudo cat /var/lib/jenkins/secrets/initialAdminPassword
Install Java 8 & Jenkins Manually: For Ubuntu 18.04
sudo apt update && upgradesudo apt install -y python3.8wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'sudo apt update -ysudo apt install -y openjdk-8-jresudo apt install -y jenkinssudo apt install -y docker docker.iosudo chmod 777 /var/run/docker.socksudo cat /var/lib/jenkins/secrets/initialAdminPassword
Setup Jenkins:
cat /var/lib/jenkins/secrets/initialAdminPassword
o/p like this:
e93a68d446a8449f9e2701fc26bccd86
How to Connect with you new provisioned Ubuntu/ Jenkins VM:
How to Install Maven:
sudo apt -y install mavenmvn --versionjava -version
How to Install & Tomcat 10:
sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcatsudo wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.23/bin/apache-tomcat-10.0.23.tar.gzsudo mkdir /opt/tomcatsudo tar xzvf apache-tomcat-10*tar.gz -C /opt/tomcat --strip-components=1sudo chown -R tomcat:tomcat /opt/tomcat/sudo chmod -R u+x /opt/tomcat/bin
Find the server.xml file & change the port Number 8080 to 8090
Our Jenkins is running on default port 8080
sudo find / -iname server.xmlsudo vim /opt/tomcat/conf/server.xmlchange port 8080 to 8090
Start the Tomcat Server 10
sudo sh /opt/tomcat/bin/bin/catalina.sh start
How to Install & Tomcat 9:
sudo apt update -y
sudo apt install tomcat9 tomcat9-admin -y
Find the server.xml file & change the port Number 8080 to 8090
Our Jenkins is running on default port 8080
sudo vim /var/lib/tomcat9/conf/server.xml<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Start the Tomcat Server 9:
sudo systemctl restart tomcat9
Open Tomcat URL: http://44.200.248.95:8090/
References:
For more info please connect & Follow me:
Github: https://github.com/manikcloud
LinkedIn: https://www.linkedin.com/in/vkmanik/
Email: varunmanik1@gmail.com
Facebook: https://www.facebook.com/cloudvirtualization/
YouTube: https://bit.ly/32fknRN
Twitter: https://twitter.com/varunkmanik