From de4d633afa931f61198d5e4c77ba6e8ce7daefa9 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:40:45 +0530 Subject: [PATCH 01/10] Create himanshu.yml --- .github/workflow/himanshu.yml | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflow/himanshu.yml diff --git a/.github/workflow/himanshu.yml b/.github/workflow/himanshu.yml new file mode 100644 index 0000000..a4fe7b0 --- /dev/null +++ b/.github/workflow/himanshu.yml @@ -0,0 +1,59 @@ +name: Azure Web App Container Deployment + +on: + push: + branches: + - master # Change this to your default branch + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Set up Docker + uses: azure/docker-login@v1 + with: + login-server: https://hub.docker.com/ + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Build and push Docker image + # run: | + # docker build -t senthilnata1/shell-java-app:0.0.1.Release . + # docker push senthilnata1/shell-java-app:0.0.1.Release + + - name: Build Docker Image + run: docker build -t himanshudxm/shell-java-app:0.0.1.Release . + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker Image + run: docker push himanshudxm/shell-java-app:0.0.1.Release + + - name: Login to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Web App + uses: azure/webapps-deploy@v2 + with: + app-name: azure-web-app-shell-java-app + images: himanshudxm/shell-java-app:0.0.1.Release From 1bd0084a6c99d9215bc7c1ec916a88beea864d39 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:42:00 +0530 Subject: [PATCH 02/10] wrong name added --- .github/workflow/himanshu.yml | 59 ----------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 .github/workflow/himanshu.yml diff --git a/.github/workflow/himanshu.yml b/.github/workflow/himanshu.yml deleted file mode 100644 index a4fe7b0..0000000 --- a/.github/workflow/himanshu.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Azure Web App Container Deployment - -on: - push: - branches: - - master # Change this to your default branch - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - - name: Build with Maven - run: mvn -B package --file pom.xml - - - name: Set up Docker - uses: azure/docker-login@v1 - with: - login-server: https://hub.docker.com/ - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - # - name: Build and push Docker image - # run: | - # docker build -t senthilnata1/shell-java-app:0.0.1.Release . - # docker push senthilnata1/shell-java-app:0.0.1.Release - - - name: Build Docker Image - run: docker build -t himanshudxm/shell-java-app:0.0.1.Release . - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push Docker Image - run: docker push himanshudxm/shell-java-app:0.0.1.Release - - - name: Login to Azure - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Deploy to Azure Web App - uses: azure/webapps-deploy@v2 - with: - app-name: azure-web-app-shell-java-app - images: himanshudxm/shell-java-app:0.0.1.Release From 5f38dbe61ca042de640d05421ca1b18a8d6511f3 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:45:21 +0530 Subject: [PATCH 03/10] Create himanshu.yml --- .github/workflows/himanshu.yml | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/himanshu.yml diff --git a/.github/workflows/himanshu.yml b/.github/workflows/himanshu.yml new file mode 100644 index 0000000..462b0e3 --- /dev/null +++ b/.github/workflows/himanshu.yml @@ -0,0 +1,47 @@ +# 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/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + #- name: Update dependency graph + # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + + - name: Build Docker image + run: docker build -t himanshudxm/github-actions-docker-java-app:0.0.1.Release . + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker Image + run: docker push himanshudxm/github-actions-docker-java-app:0.0.1.Release From 735a2f730e857f0f0ced24b94c7810ad8c456767 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:49:34 +0530 Subject: [PATCH 04/10] Create docker-compose.dev.yml --- docker-compose.dev.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..5c04515 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,6 @@ +version: '3' +services: + my-app: + image: nkmg123/github-actions-docker-java-app:0.0.1.Release + ports: + - "5000:5000" From c0f6c45f4c040cb88ce845fc64159b2141383467 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:04:43 +0530 Subject: [PATCH 05/10] Changed Branch --- .github/workflows/himanshu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/himanshu.yml b/.github/workflows/himanshu.yml index 462b0e3..e6fb441 100644 --- a/.github/workflows/himanshu.yml +++ b/.github/workflows/himanshu.yml @@ -10,9 +10,9 @@ name: Java CI with Maven on: push: - branches: [ "master" ] + branches: [ "feature" ] pull_request: - branches: [ "master" ] + branches: [ "feature" ] jobs: build: From bd23ee11f3f135e5328ea901a2c0ede5a2b66b5d Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:16:20 +0530 Subject: [PATCH 06/10] Create Dockerfile --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..973fb6a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:17-jdk-jammy as base +WORKDIR /app +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ +RUN ./mvnw dependency:resolve +COPY src ./src + +FROM base as test +RUN ["./mvnw", "test"] + +FROM base as development +CMD ["./mvnw", "spring-boot:run", "-Dspring-boot.run.profiles=mysql", "-Dspring-boot.run.jvmArguments='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000'"] + +FROM base as build +RUN ./mvnw package + +FROM eclipse-temurin:17-jre-jammy as production +EXPOSE 8080 +COPY --from=build /app/target/spring-petclinic-*.jar /spring-petclinic.jar +CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/spring-petclinic.jar"] From 8dd958893a1a14609ed08ee90a19c1198999453f Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:49:29 +0530 Subject: [PATCH 07/10] Changed distribution and maven wrapper run path --- .github/workflows/himanshu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/himanshu.yml b/.github/workflows/himanshu.yml index e6fb441..c71092c 100644 --- a/.github/workflows/himanshu.yml +++ b/.github/workflows/himanshu.yml @@ -25,10 +25,10 @@ jobs: uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'temurin' + distribution: 'adopt' cache: maven - name: Build with Maven - run: mvn -B package --file pom.xml + run: ./mvnw -B package # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive #- name: Update dependency graph From c33555df447e25366795ce43b9b3018c8709a08f Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:51:10 +0530 Subject: [PATCH 08/10] Update docker-compose.dev.yml --- docker-compose.dev.yml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 5c04515..f949dc9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,6 +1,27 @@ -version: '3' +version: "2.2" + services: - my-app: - image: nkmg123/github-actions-docker-java-app:0.0.1.Release + mysql: + image: mysql:8.0 ports: - - "5000:5000" + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD= + - MYSQL_ALLOW_EMPTY_PASSWORD=true + - MYSQL_USER=petclinic + - MYSQL_PASSWORD=petclinic + - MYSQL_DATABASE=petclinic + volumes: + - "./conf.d:/etc/mysql/conf.d:ro" + profiles: + - mysql + postgres: + image: postgres:15.3 + ports: + - "5432:5432" + environment: + - POSTGRES_PASSWORD=petclinic + - POSTGRES_USER=petclinic + - POSTGRES_DB=petclinic + profiles: + - postgres From 549c7246b6c3c2f519af7f6d27b07ce0dc68c399 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:11:57 +0530 Subject: [PATCH 09/10] Delete docker-compose.dev.yml --- docker-compose.dev.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index f949dc9..0000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: "2.2" - -services: - mysql: - image: mysql:8.0 - ports: - - "3306:3306" - environment: - - MYSQL_ROOT_PASSWORD= - - MYSQL_ALLOW_EMPTY_PASSWORD=true - - MYSQL_USER=petclinic - - MYSQL_PASSWORD=petclinic - - MYSQL_DATABASE=petclinic - volumes: - - "./conf.d:/etc/mysql/conf.d:ro" - profiles: - - mysql - postgres: - image: postgres:15.3 - ports: - - "5432:5432" - environment: - - POSTGRES_PASSWORD=petclinic - - POSTGRES_USER=petclinic - - POSTGRES_DB=petclinic - profiles: - - postgres From 5ca2377bc87291d476f9eb6caa27f8008e73c4b0 Mon Sep 17 00:00:00 2001 From: Himanshu <76443309+himanshu-dxm@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:14:41 +0530 Subject: [PATCH 10/10] added docker-compose --- docker-compose.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ef62437 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: "2.2" + +services: + my-app: + image: himanshudxm/github-actions-docker-java-app:0.0.1.Release + ports: + - "5000:5000" + mysql: + image: mysql:8.0 + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD= + - MYSQL_ALLOW_EMPTY_PASSWORD=true + - MYSQL_USER=petclinic + - MYSQL_PASSWORD=petclinic + - MYSQL_DATABASE=petclinic + volumes: + - "./conf.d:/etc/mysql/conf.d:ro" + profiles: + - mysql + postgres: + image: postgres:15.3 + ports: + - "5432:5432" + environment: + - POSTGRES_PASSWORD=petclinic + - POSTGRES_USER=petclinic + - POSTGRES_DB=petclinic + profiles: + - postgres