diff --git a/.github/workflows/main_pet123.yml b/.github/workflows/main_pet123.yml new file mode 100644 index 0000000..c5c0262 --- /dev/null +++ b/.github/workflows/main_pet123.yml @@ -0,0 +1,51 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy container app to Azure Web App - pet123 + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: https://index.docker.io/v1/ + username: ${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }} + password: ${{ secrets.AzureAppService_ContainerPassword_b15af5738db5488480ecbd3367145ea3 }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v3 + with: + push: true + tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }}/pet1:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'pet123' + slot-name: 'production' + publish-profile: ${{ secrets.AzureAppService_PublishProfile_2e615b003508405795b936400243d16c }} + images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_c7864b7e845e4c6883463d1388c9d9cb }}/pet1:${{ github.sha }}' \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..a577ebc --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# 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: [ "main" ] + pull_request: + branches: [ "main" ] + +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: ./mvnw clean package + + # 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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7fdce7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use a base image with Java 17 and Alpine Linux +FROM openjdk:17.0.2-slim + +# Set the working directory +WORKDIR / + +# Expose port 80 +EXPOSE 80 + +# Copy the JAR file into the container +COPY target/spring-petclinic-3.1.0-SNAPSHOT.jar /app.jar + +# Set the entry point to run the application +ENTRYPOINT ["java", "-jar", "/app.jar"]