================================= DevOps Project Setup (3 Tier) ================================= => Our application contains 3 layers 1) Database (MySQL) 2) Backend Application (Java SprinBoot) 3) Frontend Application (Angular) =================== DB Setup =================== Step-1 :: Setup AWS RDS MySQL Instance and note down DB details DB Endpoint : mysql-dev-db.cjmqwwo0a08x.ap-south-1.rds.amazonaws.com DB Username : admin DB Password : AshokIT321 Step-2 :: Connect with MySQL DB using Workbench s/w and execute sql queries to insert products data into db tables. Note: DB Queries file available in backend_app git repo # Backend App Git Repo : https://github.com/ashokitschool/01_products_api.git DB Queries File Name: DB_Setup.sql ########################### Backend Api Deployment ############################ ============== Jenkins Setup ============== @@@ Step-1 :: Setup Jenkins Server : https://github.com/ashokitschool/DevOps-Documents/blob/main/01-Jenkins-Server-Setup.md uname : ashokit pwd : ashokit @@@ Step-2 :: Configure Maven as Global Tool in Jenkins Manage Jenkins -> Tools -> Maven Installation -> Add maven Maven Tool name : Maven-3.9.10 @@@ Step-3 :: Configure RDS DB instance connectivity Details in backend app git repo # Backend App Git Repo : https://github.com/ashokitschool/01_products_api.git File to change : src/main/resources/application.properties @@@ Step-4 :: Create CI JOB to build backend application Stage-1 : Clone Git Repo Stage-2 : Maven Build ``` pipeline { agent any tools{ maven "Maven-3.9.10" } stages { stage('Git clone') { steps { git branch: 'main', url: 'https://github.com/ashokitschool/01_products_api.git' } } stage('Mvn Build') { steps { sh 'mvn clean package' } } } } ``` ======================= SonarQube Integration ======================= @@@ Step-1 :: Setup SonarQube Server @@ Steps : https://github.com/ashokitschool/DevOps-Documents/blob/main/06-Sonar-Setup-Docker.md @@ Generate Sonar Token : sqa_ae95877407c19c7b633dd5c66a579efc3fe2c943 @@@ Step-2 :: Add Sonar Token in 'Jenkins Credentials' as Secret Text -> Manage Jenkins -> Credentials -> Add Credentials -> Select Secret text -> Enter Sonar Token as secret text @@@ Step-3 :: Install SonarQube Scanner Plugin -> Manage Jenkins -> Plugins -> Available -> Sonar Qube Scanner Plugin -> Install it @@@ Step-4 :: Configure SonarQube Server -> Manage Jenkins -> Configure System -> Sonar Qube Servers -> Add Sonar Qube Server - Name : Sonar-Server-AIT - Server URL : http://52.66.247.11:9000/ - Select Sonar Server Token @@@ Step-5 :: Add SonarQube Stage in Jenkins Pipeline ``` stage('Code Review') { steps { withSonarQubeEnv('Sonar-Server-AIT'){ sh 'mvn sonar:sonar' } } } ``` ================== Nexus Integration ================== @@@ Step-1 :: Setup Nexus Server Steps : https://github.com/ashokitschool/DevOps-Documents/blob/main/07-Nexus-Setup-Docker.md Username : admin Pwd : AshokIT321 @@@ Step-2 :: Create Repository in Nexus Repo Type : Maven2 (Hosted) repo name : ashokit-artifact-repo Repo Url : http://43.205.213.177:8081/repository/ashokit-artifact-repo/ @@@ Step-3 :: Install Nexus Repository Plugin -> Manage Plugins -> Available Pluging -> Plugin Name : Nexus Artifact Uploader @@@ Step-4 :: Configure Nexus Upload stage in Jenkins Pipeline (use pipeline syntax to generate script) ``` stage('Nexus Upload') { steps { nexusArtifactUploader artifacts: [ [ artifactId: '01_products_api', classifier: '', file: 'target/products_api.jar', type: 'jar' ] ], credentialsId: 'NEXUS-CREDENTIALS', groupId: 'in.ashokit', nexusUrl: '43.205.213.177:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'ashokit-artifact-repo', version: '1.0' } } ``` ==================== Docker Integration ==================== @@@ Step-1 :: Setup Docker s/w in Jenkins Server ``` sudo apt update curl -fsSL get.docker.com | /bin/bash sudo usermod -aG docker ubuntu sudo usermod -aG docker jenkins sudo systemctl restart docker sudo systemctl restart jenkins exit ``` @@@ Step-2 :: Add Stage to create Docker Image ``` stage('Docker Image') { steps { sh 'docker build -t ashokit/ecomm_backend_api .' } } ``` @@@ Step-3 :: Add Stage to Push Docker Image to docker Hub stage('Push Docker Image') { steps { sh 'docker login -u ashokit -p token' sh 'docker push ashokit/ecomm_backend_api' } } ============================================================================================