From 4ac8f0e95dd78dfce8378d57bfdc11938520bfaa Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Wed, 21 May 2025 10:56:34 +0530 Subject: [PATCH 1/8] Added Dockerfile Signed-off-by: vinayasuresh --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..eefe5fcff --- /dev/null +++ b/Dockerfile @@ -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"] From 99fb96f1157ffd2879c0340047bfb80033431c0f Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Wed, 21 May 2025 10:57:13 +0530 Subject: [PATCH 2/8] Create Jenkinsfile Signed-off-by: vinayasuresh --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..e12ee2189 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,16 @@ + +pipeline { + agent none + stages { + stage('Maven Install') { + agent { + docker { + image 'maven:3.5.0' + } + } + steps { + sh 'mvn clean install' + } + } + } + } From c5252027b7b50c80cebca1d746503a6995458ea7 Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Fri, 23 May 2025 16:18:49 +0530 Subject: [PATCH 3/8] dockerfile --- .github/dco.yml | 2 -- .github/workflows/ci-cd.yml | 33 +++++++++++++++++++ .github/workflows/deploy-and-test-cluster.yml | 31 ----------------- .github/workflows/gradle-build.yml | 31 ----------------- .github/workflows/maven-build.yml | 29 ---------------- Jenkinsfile | 16 --------- 6 files changed, 33 insertions(+), 109 deletions(-) delete mode 100644 .github/dco.yml create mode 100644 .github/workflows/ci-cd.yml delete mode 100644 .github/workflows/deploy-and-test-cluster.yml delete mode 100644 .github/workflows/gradle-build.yml delete mode 100644 .github/workflows/maven-build.yml delete mode 100644 Jenkinsfile diff --git a/.github/dco.yml b/.github/dco.yml deleted file mode 100644 index 37e411e1b..000000000 --- a/.github/dco.yml +++ /dev/null @@ -1,2 +0,0 @@ -require: - members: false \ No newline at end of file diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 000000000..7280a35a8 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -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: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/spring-petclinic:latest diff --git a/.github/workflows/deploy-and-test-cluster.yml b/.github/workflows/deploy-and-test-cluster.yml deleted file mode 100644 index 7353a604b..000000000 --- a/.github/workflows/deploy-and-test-cluster.yml +++ /dev/null @@ -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 - diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml deleted file mode 100644 index c24c121b1..000000000 --- a/.github/workflows/gradle-build.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml deleted file mode 100644 index a1ec4dab7..000000000 --- a/.github/workflows/maven-build.yml +++ /dev/null @@ -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 diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index e12ee2189..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,16 +0,0 @@ - -pipeline { - agent none - stages { - stage('Maven Install') { - agent { - docker { - image 'maven:3.5.0' - } - } - steps { - sh 'mvn clean install' - } - } - } - } From b2a169a44c5949fb4e8e4526e5f2657919a7a35f Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Fri, 23 May 2025 16:21:33 +0530 Subject: [PATCH 4/8] 2 --- .github/workflows/ci-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7280a35a8..443baaf92 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -22,7 +22,7 @@ jobs: - name: Log in to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} + username: vinayasuresh password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image @@ -30,4 +30,4 @@ jobs: with: context: . push: true - tags: ${{ secrets.DOCKER_USERNAME }}/spring-petclinic:latest + tags: vinayasuresh/spring-petclinic:latest From 4d7c8904837ab48e79fe021efa3a05cd5853c253 Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Mon, 23 Jun 2025 12:20:35 +0530 Subject: [PATCH 5/8] Create jenkinsfile Signed-off-by: vinayasuresh --- jenkinsfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 000000000..9acb62687 --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,27 @@ +pipeline { + agent any + + environment { + IMAGE_NAME = 'app' + } + + stages { + stage('Clone') { + steps { + git 'https://github.com/vinayasuresh/spring-petclinic' + } + } + + stage('Build Docker Image') { + steps { + sh 'docker build -t $IMAGE_NAME .' + } + } + + stage('Run Container') { + steps { + sh 'docker run -d --rm --name spring-petfield -p 3000:3000 $IMAGE_NAME' + } + } + } +} From 1cc41447c7555126bc673784bd8b783f97e9f824 Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Tue, 24 Jun 2025 12:18:14 +0530 Subject: [PATCH 6/8] Update and rename jenkinsfile to Jenkinsfile Signed-off-by: vinayasuresh --- Jenkinsfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ jenkinsfile | 27 --------------------------- 2 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 Jenkinsfile delete mode 100644 jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..ef10412bb --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,45 @@ +pipeline { + agent any + + environment { + IMAGE_NAME = "local-app:latest" + CONTAINER_NAME = "local-app-container" + } + + stages { + stage('Checkout') { + steps { + git 'https://github.com/vinayasuresh/spring-petclinic.git' + } + } + + 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 + ''' + } + } + } +} diff --git a/jenkinsfile b/jenkinsfile deleted file mode 100644 index 9acb62687..000000000 --- a/jenkinsfile +++ /dev/null @@ -1,27 +0,0 @@ -pipeline { - agent any - - environment { - IMAGE_NAME = 'app' - } - - stages { - stage('Clone') { - steps { - git 'https://github.com/vinayasuresh/spring-petclinic' - } - } - - stage('Build Docker Image') { - steps { - sh 'docker build -t $IMAGE_NAME .' - } - } - - stage('Run Container') { - steps { - sh 'docker run -d --rm --name spring-petfield -p 3000:3000 $IMAGE_NAME' - } - } - } -} From ae5e0a0f48e3685eae453beba273f5424705cc44 Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Tue, 24 Jun 2025 12:37:16 +0530 Subject: [PATCH 7/8] Update Jenkinsfile Signed-off-by: vinayasuresh --- Jenkinsfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ef10412bb..1233928c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,12 +7,6 @@ pipeline { } stages { - stage('Checkout') { - steps { - git 'https://github.com/vinayasuresh/spring-petclinic.git' - } - } - stage('Build App') { steps { sh 'mvn clean package -DskipTests' From 5fb1726b541e685f326229d74323f920f5785244 Mon Sep 17 00:00:00 2001 From: vinayasuresh Date: Tue, 24 Jun 2025 12:39:16 +0530 Subject: [PATCH 8/8] Update Jenkinsfile Signed-off-by: vinayasuresh --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1233928c5..96ef7b69b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,9 @@ pipeline { - agent any + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + } environment { IMAGE_NAME = "local-app:latest"