Skip to content

kirancgwd/Java_Blogging_App_CICD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Blogging APP

Run in local system

Tools Required

1.Java Development Kit (JDK)

2.Apache Maven

3.Git (Optional)

4.IDE (Optional)

Instructions to Run the Project

Step 1: Clone the Project

git clone

Step 2: Navigate to the Project Directory

cd

Step 3: Verify Java and Maven Installation

java -version

mvn -version

Step 4: Build the Project

mvn clean install

Step 5: Run the Application

mvn spring-boot:run

Step 6: Access the Application

http://localhost:8082

Project Setup in Cloud

Github --> Jenkins --> Compile & Testing --> Trivy Fs Scan --> Quality Gate Check --> SonarQube --> Docker Image create --> Trivy Image Scan --> Docker Container Create

Infra Setup

  1. VM or EC2 -- AWSCLI, Git
  2. CICD Server -- Jenkins AND Jenkins Slave -- java, Trivy, Docker
  3. Code Analisys and Artifact Storage -- SonarQube, Nexus

AWS Instance Creation

We need 2 ubuntu servers with 25GB Storage

  1. Jenkins(t2.large)
  2. SonarQube and Nexus (t2.large )

Setup Jenkins

  1. Install Java
apt-get update
sudo apt install openjdk-17-jdk
  1. Install Jekins
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
sudo systemctl start jenkins
  1. Install Docker
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker jenkins
Restart jenkins
  1. Install Trivy
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
  1. Login Jenkins UI and install pluggins

IP-ADDRESS:8080

sonarqube-scanner
Config file provider
maven integeration
pipeline maven integration maven
nexus artifact uploader
docker
owasp
docke pipeline
eclipse temurin installer
pipeline.stage view
Kub client API
Kub Credentials
Kubernetes
Kub CLI
Kub Credentials provider
Generic webhook trigger

Setp SonarQube and Nexus

  1. Install Docker
apt install docker.io
sudo usermod -aG docker $USER
newgrp docker
  1. Create Sonarqube server using Docker image
docker run -d --name sonar -p 9000:9000 --restart=always sonarqube:latest
  1. Create Nexus Server using Docker image
docker run -d --name nexus -p 8081:8081 -p 5000:5000 --restart=always  sonatype/nexus3
  1. Add Nexus URL in pom.xml

Login to Nexus --> browse --> copy maven releases and maven snapshots ---> paste in URL added in pom.xml

image

  1. Edit pom.xml

image

  1. Create gloabl maven configuration in jenkins managed files

Goto managed files --> add new config --> select Global Maven settings.xml --> give ID as Global-maven --> add below config under server --> username and password of nexus

-->
    <server>
      <id>maven-releases</id>
      <username>admin</username>
      <password>kirancgwd</password>
    </server>
    
    <server>
      <id>maven-snapshots</id>
      <username>admin</username>
      <password>kirancgwd</password>
    </server>
    -->

Add Docker sonarqube Credentials in Jenkins

  1. Create token in Sonarqube and add in jenkins
  2. Take Docker registry username and password & add it in Jenkins
  3. Add Sonar server in Jenkins System configuration by selecting Sonarqube credentials.

Create pipeline using Jenkins Files

About

Application deployment to Docker container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published