diff --git a/.github/workflows/azure-webapps-deploy.yml b/.github/workflows/azure-webapps-deploy.yml new file mode 100644 index 0000000..4afdd85 --- /dev/null +++ b/.github/workflows/azure-webapps-deploy.yml @@ -0,0 +1,63 @@ +name: Build and deploy a container to an Azure Web App + +env: + AZURE_WEBAPP_NAME: kinman-openapi-demo + +on: + push: + branches: + - main + +permissions: + contents: 'read' + packages: 'write' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + - name: Build with Maven + run: mvn --batch-mode --update-snapshots package -DskipTests + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to GitHub container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Lowercase the repo name + run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + - name: Build and push container image to registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/${{ env.REPO }}:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + + needs: build + + steps: + - name: Lowercase the repo name + run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}' + slot-name: staging \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2eaf1ee..4fee1e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ COPY --from=builder application/snapshot-dependencies/ ./ COPY --from=builder application/application/ ./ ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] -EXPOSE 8080 \ No newline at end of file +#EXPOSE 8080 \ No newline at end of file diff --git a/docker-compose-prd.yaml b/docker-compose-prd.yaml index 6d70c50..3cd7054 100644 --- a/docker-compose-prd.yaml +++ b/docker-compose-prd.yaml @@ -6,7 +6,7 @@ services: build: context: . ports: - - "8080:8080" + - "80:8080" container_name: app depends_on: - db