This commit is contained in:
vinayasuresh 2025-07-07 11:06:40 +05:30 committed by GitHub
commit 9203eda07b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 80 additions and 93 deletions

2
.github/dco.yml vendored
View file

@ -1,2 +0,0 @@
require:
members: false

33
.github/workflows/ci-cd.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: CI/CD - Docker Build & Push
on:
push:
branches:
- main # or change to your main branch name
pull_request:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: vinayasuresh
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: vinayasuresh/spring-petclinic:latest

View file

@ -1,31 +0,0 @@
name: Deploy and Test Cluster
on:
push:
branches: [main]
paths:
- 'k8s/**'
pull_request:
branches: [main]
paths:
- 'k8s/**'
jobs:
deploy-and-test-cluster:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Deploy application
run: |
kubectl apply -f k8s/
- name: Wait for Pods to be ready
run: |
kubectl wait --for=condition=ready pod -l app=demo-db --timeout=180s
kubectl wait --for=condition=ready pod -l app=petclinic --timeout=180s

View file

@ -1,31 +0,0 @@
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v4
with:
java-version: ${{matrix.java}}
distribution: 'adopt'
cache: maven
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew build

View file

@ -1,29 +0,0 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v4
with:
java-version: ${{matrix.java}}
distribution: 'adopt'
cache: maven
- name: Build with Maven Wrapper
run: ./mvnw -B verify

4
Dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM anapsix/alpine-java
LABEL maintainer="shanem@liatrio.com"
COPY /target/spring-petclinic-1.5.1.jar /home/spring-petclinic-1.5.1.jar
CMD ["java","-jar","/home/spring-petclinic-1.5.1.jar"]

43
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,43 @@
pipeline {
agent {
docker {
image 'maven:3.9.6-eclipse-temurin-17'
}
}
environment {
IMAGE_NAME = "local-app:latest"
CONTAINER_NAME = "local-app-container"
}
stages {
stage('Build App') {
steps {
sh 'mvn clean package -DskipTests'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t $IMAGE_NAME .'
}
}
stage('Stop Existing Container') {
steps {
sh '''
docker stop $CONTAINER_NAME || true
docker rm $CONTAINER_NAME || true
'''
}
}
stage('Run Docker Container') {
steps {
sh '''
docker run -d --name $CONTAINER_NAME -p 8080:8080 $IMAGE_NAME
'''
}
}
}
}