https://github.com/anindyadas2001/petcaremanager
My First DevOps Project
https://github.com/anindyadas2001/petcaremanager
ansible app aws beginner-friendly database devops terraform
Last synced: about 1 year ago
JSON representation
My First DevOps Project
- Host: GitHub
- URL: https://github.com/anindyadas2001/petcaremanager
- Owner: anindyadas2001
- Created: 2024-09-20T17:56:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-16T13:16:49.000Z (over 1 year ago)
- Last Synced: 2024-10-19T11:08:03.940Z (over 1 year ago)
- Topics: ansible, app, aws, beginner-friendly, database, devops, terraform
- Homepage:
- Size: 1.83 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🐾 Spring PetCare Manager 













**Spring PetCare Manager** improves the [>>Referance App<<](https://github.com/spring-projects/spring-petclinic) which was a application built with Spring Boot, designed for managing pet care services like appointments, veterinarian schedules, and pet records. It adds a robust DevOps Pipeline to make the app deliverable.
```
The project is in development. You are open to contributing to it.
```
## ➡️ Further Developments are made in this repository:
***👉 Here, the app is deployed using a seamlessly automated DevOps pipeline :***
> - ReDesigned the Project Object Model
> - Replaced H2 Engine with PostGre SQL database
> - Made a Jenkins pipeline containing JUnit and SonarQube extensions.
> - Developed a enterprise with Dev and QA Tomcat enviromnents with a stage gate.
> - Future prospects of implementing IaC with Teraform creating and Ansible for configuring resources/services in the AWS architechure, which was designed with security measures in mind
## 🎯 **Features & Technologies**
- [x] **Development**: Java App made using Spring Boot (Manage Pet Owners, Pets, Veterinarians, Appointments, and Services).
- [x] **Database**: PostgreSQL for handling interconnected entities with relational data models.
- [x] **Source Control Management**: Github
- [X] **Continuous Integration**: Using Jenkins
- [x] JUnit Exteension for Testing
- [x] SonarQube for Continuous monitoring, analysis and Report visualisation.
- [ ] Storing the generated Report.
- [x] **Testing and Analysis**: Extensions such as JUnit & SonarQube.
- [x] **Continuous Delivery**: Using IaC with AWS Cloud to Deliver the App
- [x] Cloud Native: AWS Architecture:
- [x] VPC : Single Region
- [x] Subnets:
- [x] EC2 instances for hosting
- [x] RDS for PostgreSQL frequeltly used data
- [x] S3 for App Rollback storage
- [x] IAM for Policy management
- [ ] IaC: Automate provisioning of AWS infrastructure and environment setup
- [ ] Ansible
- [ ] Teraform
- [x] **Linux Shell & Networking**: Basic Linux and networking configurations for server management.
## 🌐 **System Architecture** made using draw.io
- [x] `CI/CD Pipeline - NON IaC`

## 🚀 **Java App Modification Instructions**
### 1️⃣ **Clone the Refferance Repository**
```bash
https://github.com/anindyadas2001/PetCareManager.git
cd PetCareManager
```
## Extract the
```
extractdir.zip
```
### 2️⃣ **Database Configuration (PostgreSQL)**
- Navigate to the `src/main/resources` directory and locate the `application.properties` file.
- Update it with your PostgreSQL credentials:
```properties
spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update
```
> [!Note]
> Ensure PostgreSQL is installed and running on your local/remote server before proceeding.
### 3️⃣ **Build and Run the Application**
- To build and run the application, execute the following Maven command:
```bash
./mvnw package
java -jar target/*.jar
```
> [!Tip]
> You can access the running application at `http://localhost:8080` after successful execution.
### 4️⃣ **Deploy on Tomcat**
- Package the application into a WAR file and deploy it on Tomcat:
```bash
./mvnw clean package
```
- Deploy the WAR file on the Apache Tomcat web server:
- Place the `war` file inside the `Tomcat/webapps` directory.
- Start/restart the Tomcat server.
> [!Important]
> You can monitor the deployment at `http://:8080/`
- Place the `war` file in the Tomcat `webapps/` directory.
### 5️⃣ **CI/CD with Jenkins**
- Create a new Jenkins pipeline project.
- Connect your GitHub repository and configure automatic triggers.
- Define build steps for packaging and deploying the WAR file.
```groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
sh './mvnw clean package'
}
}
stage('Test') {
steps {
sh './mvnw test'
}
}
stage('Deploy') {
steps {
// Deployment steps (Tomcat, AWS, etc.)
}
}
}
}
```
> [!Note]
> Use Jenkins to schedule automated builds on every commit.
### 6️⃣ **Monitoring and Code Quality**
- Use SonarQube to ensure code quality and reduce technical debt.
- Set up SonarQube by running the following command:
```bash
sonar-scanner -Dsonar.projectKey=PetCareManager
```
## **AWS Services Modifications:**
- IAM Role for S3 Access:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
```
- Create a Backup Script:
``` bash
#!/bin/bash
# Variables
APP_DIR="/path/to/your/java/app" # The directory where your Java app is located
BACKUP_FILE="/tmp/java-app-backup-$(date +%Y%m%d%H%M%S).tar.gz"
S3_BUCKET="your-bucket-name"
S3_PATH="s3://${S3_BUCKET}/backups/java-app-$(date +%Y%m%d%H%M%S).tar.gz"
# Create a tar.gz backup of the Java app directory
tar -czvf $BACKUP_FILE -C $APP_DIR .
# Upload the backup to S3
aws s3 cp $BACKUP_FILE $S3_PATH
# Optionally, remove the local backup file
rm -f $BACKUP_FILE
echo "Backup complete. File uploaded to $S3_PATH"
```
> Automate the Script Execution:
> create a cron job `$ crontab -e`
> Add a cron entry to run the script at a specific time ``
- Connecting Tomcat to EBS:
- [Java app to EBS](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html)
- [Elastic Beanstalk & Tomcat](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html)
- In Private EC2 instance to recognise the data inside RDS run the following commands:
```bash
# To Update all dependencies
sudo yum update && upgrade
# To install PostgreSQL
sudo yum install postgresql
# To cheak version
psql --version
#Connect to the RDS database
sudo su
psql -h -U -d -p 5432 --sslmode=verify-full
#Verify and show data base:
SELECT * FROM pg_database
```
### 📋 **Project Management**
- Track progress, database schema, and tasks using Notion Dashboard.
### 🤝 **Contributions**
`You are welcome contributions! Please feel free to:`
- Open an issue for any bugs or suggestions.
- Submit a pull request to improve the application.
### 📝 **Project Highlights**
- Built a scalable Spring Boot web application and deployed it on Apache Tomcat.
- Automated build, test, and deployment using a Jenkins CI/CD pipeline and SonarQube for code quality checks.
- Provisioned and managed AWS infrastructure using Ansible with a focus on Infrastructure as Code (IaC).