Skip to content

This project demonstrates a complete CI/CD pipeline setup for the Spring PetClinic application deployed on AWS. It automates infrastructure provisioning, configuration management, and application deployment using industry-standard DevOps tools.

Notifications You must be signed in to change notification settings

MuhanedAhmed/Java-Spring-App-CI-CD-Pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏥 Spring PetClinic on AWS with CI/CD Pipeline

This project automates the deployment of the Spring PetClinic application using modern DevOps tools and practices. It provisions infrastructure on AWS using Terraform, configures environments with Ansible, builds and deploys the app through a Jenkins CI/CD pipeline, and containerizes the application using Docker.


📌 Architecture Diagram

This project is based on a modular infrastructure and automated CI/CD pipeline designed using Terraform, Ansible, Jenkins, and Docker on AWS.

The following diagram illustrates the complete infrastructure and CI/CD flow:

AWS Architecture Diagram


📁 Project Structure


.
├── Ansible-Part/              # Ansible playbooks & roles for configuration
├── Docker-Part/               # Dockerfile for app containerization
├── Jenkins-Part/              # Jenkins pipeline script
├── Pics/                      # Architecture & pipeline diagrams
├── Scripts/                   # Helper bash scripts
├── Source-Code/               # Spring PetClinic source code
└── Terraform-Part/            # Infrastructure as Code for AWS resources


📦 Tech Stack

Tool Purpose
Terraform Infrastructure provisioning
Ansible Server configuration
Jenkins CI/CD pipeline orchestration
Docker App containerization
AWS Cloud hosting environment
Maven Java project build tool

Terraform Ansible Jenkins Docker AWS Java Maven


🧰 Prerequisites

Before you begin, ensure you have the following tools installed:

Use the provided script to automatically check:

chmod +x Scripts/check_prerequisites.sh
./Scripts/check_prerequisites.sh

Check Prerequisites


🚀 Deployment Steps

1. Make Scripts Executable

chmod +x Scripts/infra_setup.sh Scripts/infra_cleanup.sh

2. Setup Infrastructure and Configure Jenkins

./Scripts/infra_setup.sh

This script performs the following:

  • Provisions AWS infrastructure using Terraform:

    • VPC, Subnets, Security Groups, EC2 instances, ALB, and RDS
  • Copies SSH key and Ansible files to Jenkins server

  • Configures Jenkins, Docker, and Maven using Ansible

  • Deploys the Spring PetClinic backend inside a container on Jenkins server

  • Retrieves:

    • Jenkins initial admin password and public IP
    • RDS Private Endpoint
    • Application Load Balancer URL

Infra Provisioning Infra Provisioning

⚠️ Note: Target Group is Unhealthy (Expected)

At this stage, the infrastructure has been provisioned, and the Load Balancer has been created. However, the Target Group will show as unhealthy — this is expected because the application hasn't been deployed yet via Jenkins.

Unhealthy Load Balancer


3. Access Jenkins and Trigger CI/CD Pipeline

  • Open Jenkins URL in browser: http://<JENKINS_PUBLIC_IP>:8080
  • Log in with the retrieved password (printed at the end of infra_setup.sh)

Unloack Jenkins

⚠️ Important: Before running the pipeline, make sure to replace the placeholder values <your-dockerhub-user> and <your-rds-endpoint> in the Jenkinsfile with your actual DockerHub username and RDS endpoint. Replace with new values

  • Run the job to:

    • Build the application with Maven
    • Build and push Docker image to DockerHub
    • Deploy the containerized app

Successful job


4. Access the Application

Now, the Target Group behind the Load Balancer should show a healthy status — the application container is up and running on the Jenkins server.

Healthy Load Balancer

Running App

Once the Jenkins job completes, access the app at:

http://<ALB_DNS_NAME>:80

Access the App


🧹 Cleanup Resources

To destroy everything created and free up AWS resources:

./Scripts/infra_cleanup.sh

This script will:

  • Terminate all resources provisioned by Terraform
  • Delete local key files and temporary artifacts

👨‍💻 Author

Mohaned Ahmed Cloud & DevOps Engineer GitHub Profile | LinkedIn

About

This project demonstrates a complete CI/CD pipeline setup for the Spring PetClinic application deployed on AWS. It automates infrastructure provisioning, configuration management, and application deployment using industry-standard DevOps tools.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published