From 306d19a370f30b55fa81690d7846a9754ed627a5 Mon Sep 17 00:00:00 2001 From: Daniel Meier Date: Tue, 2 Apr 2024 18:23:58 +0200 Subject: [PATCH] Test Publishing of JVM Images --- .gitattributes | 6 ++++ .github/workflows/check.yml | 14 ++------ .github/workflows/publish.yml | 55 +++++++++++++++++++---------- app/build.gradle.kts | 9 +++-- app/src/main/docker/Dockerfile.jvm | 23 ++++++++++++ gradle/wrapper/gradle-wrapper.jar | Bin 43452 -> 43453 bytes 6 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 app/src/main/docker/Dockerfile.jvm diff --git a/.gitattributes b/.gitattributes index 4fa27a3..f62b15b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,9 @@ *.bat text eol=crlf * text eol=lf +*.html text diff=html +*.java text diff=java +*.css text diff=css + +*.jar binary +*.png binary \ No newline at end of file diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 778483a..4982619 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -15,24 +15,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 - name: Run Gradle 'build' Task run: ./gradlew build - - #- name: Copy OpenAPI Specification - # run: ./gradlew copyOpenApiSpec - - #- name: Build Svelte App - # uses: docker/build-push-action@v4 - #with: - #context: web \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9ecb5f4..48f9d60 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,25 +1,31 @@ -name: Publish Docker image +name: Publish Artifacts on: release: types: [ released, prereleased ] jobs: - push_to_registry: - name: Push Docker images to Docker Hub + publish_artifacts: + name: Publish Artifacts runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -27,21 +33,34 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and Push Backend Image - run: ./gradlew build -Dquarkus.native.compression.level=9 -Dquarkus.container-image.push=true + #- name: Build and Push Native Image + # env: + # QUARKUS_CONTAINER_IMAGE_BUILD: true + # QUARKUS_CONTAINER_IMAGE_PUSH: true + # QUARKUS_PACKAGE_TYPE: native + # QUARKUS_NATIVE_COMPRESSION_LEVEL: 9 + # run: ./gradlew build - - name: Copy Linux Binary to Temporary Folder - run: cp app/build/tsa-*-runner $RUNNER_TEMP/tsa-linux-amd64 + #- name: Copy Linux Binary to Temporary Folder + # run: cp app/build/tsa-*-runner $RUNNER_TEMP/tsa-linux-amd64 - - name: Upload Linux Binary as Release Asset - uses: actions/upload-release-asset@v1 + #- name: Upload Linux Binary as Release Asset + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ github.event.release.upload_url }} + # asset_path: ${{ runner.temp }}/tsa-linux-amd64 + # asset_name: tsa-linux-amd64 + # asset_content_type: application/octet-stream + + - name: Build and Push JVM Images env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ${{ runner.temp }}/tsa-linux-amd64 - asset_name: tsa-linux-amd64 - asset_content_type: application/octet-stream + QUARKUS_CONTAINER_IMAGE_BUILD: true + QUARKUS_CONTAINER_IMAGE_PUSH: true + QUARKUS_PACKAGE_TYPE: jar + QUARKUS_DOCKER_BUILDX_PLATFORM: linux/amd64,linux/arm64 + run: ./gradlew clean assemble -PimageTagSuffix=jvm - name: Update Docker Hub description if: ${{ github.event.action == 'released' }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bb68b61..cb00094 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -84,9 +84,14 @@ spotless { quarkus { set("native.container-build", "true") - set("container-image.build", "true") set("container-image.group", "dnl50") set("container-image.name", "tsa-server") - set("package.type", "native") + set("container-image.tag", objects.property().value(provider { + if (project.hasProperty("imageTagSuffix")) { + "${project.version}-${project.property("imageTagSuffix")}" + } else { + project.version.toString() + } + })) finalName.set("tsa-${project.version}") } diff --git a/app/src/main/docker/Dockerfile.jvm b/app/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..1a81c6c --- /dev/null +++ b/app/src/main/docker/Dockerfile.jvm @@ -0,0 +1,23 @@ +# Based on Quarkus' Dockerfile.jvm template for Gradle +FROM registry.access.redhat.com/ubi8/openjdk-21-runtime:1.19 + +ENV LANGUAGE='en_US:en' + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 build/quarkus-app/*.jar /deployments/ +COPY --chown=185 build/quarkus-app/app/ /deployments/app/ +COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/ + +USER root +RUN mkdir -p /work/data \ + && chown -R 185:root /work + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +VOLUME ["/work/data"] + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8b437bdeab6ec76716a39711cdc491c5ac03c0b4..e6441136f3d4ba8a0da8d277868979cfbc8ad796 100644 GIT binary patch delta 16 YcmdmUnQ8B3rVUaFjJ%tr5*B#^06mWebN~PV delta 14 WcmdmcnQ6~urVUaFo23&Lc>(}5r3PmJ