diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 45a156403..088e820b5 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,6 +4,9 @@ on: push: branches: [ development, release-* ] +env: + IMAGE_NAME: ${{ github.repository }} + jobs: build_and_publish: runs-on: ubuntu-latest @@ -54,15 +57,17 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ghcr.io/${GITHUB_REPOSITORY} + images: ghcr.io/${{ env.IMAGE_NAME }} - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . push: true - tags: ghcr.io/${GITHUB_REPOSITORY}:${{ steps.semantic.outputs.release-version }} + tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.semantic.outputs.release-version }} labels: ${{ steps.meta.outputs.labels }} + build-args: + - VERSION: ${{ steps.semantic.outputs.release-version }} - name: Publish tag uses: actions-ecosystem/action-push-tag@v1 diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 22e18b688..cf3971513 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -4,6 +4,9 @@ on: pull_request: branches: [ development, release/** ] +env: + IMAGE_NAME: ${{ github.repository }} + jobs: java_build: runs-on: ubuntu-latest @@ -14,7 +17,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '17' - distribution: 'temirin' + distribution: 'temurin' - name: Test run: ./gradlew test - name: Build @@ -31,4 +34,4 @@ jobs: with: context: . push: false - tags: ghcr.io/${ GITHUB_REPOSITORY }:test + tags: ghcr.io/${{ env.IMAGE_NAME }}:test diff --git a/Dockerfile b/Dockerfile index 2363247db..e53b9b885 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,11 @@ -ENV WORKDIR /app -ENV PORT 8080 -ENV VERSION undefined - FROM eclipse-temurin@sha256:039f727ed86402f37524b5d01a129947e2f061d5856901d07d73a454e689bb13 AS builder -WORKDIR $WORKDIR +ARG VERSION undefined +ENV VERSION=$VERSION +WORKDIR /app COPY . . RUN ./gradlew build -x test -Pversion=$VERSION FROM eclipse-temurin@sha256:e90e0d654765ab3ae33f5c5155daafa4a907d0d738ce98c3be8f402a8edcee2b -WORKDIR $WORKDIR -COPY --from=builder $APP_HOME/build/libs/*jar . +ENV PORT 8080 +WORKDIR /app +COPY --from=builder /app/build/libs/*jar . diff --git a/readme.md b/readme.md index 80d80090c..54c65ec26 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,8 @@ # Spring PetClinic Sample Application [![Build Status](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml/badge.svg)](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml) + + + [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/spring-projects/spring-petclinic) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=7517918)