From 9cc9b817c62b8a3069e4a9e66cadd036b93711ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horv=C3=A1th=20Istv=C3=A1n?= Date: Thu, 5 Sep 2024 13:50:12 +0200 Subject: [PATCH] Use Spring Boots way of building optimized images --- .github/workflows/build-candidate.yml | 11 ++++------- .github/workflows/build-release.yml | 11 ++++------- backend/build.gradle.kts | 10 ++++++++++ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-candidate.yml b/.github/workflows/build-candidate.yml index 66cf8c168..f7655970b 100644 --- a/.github/workflows/build-candidate.yml +++ b/.github/workflows/build-candidate.yml @@ -25,17 +25,14 @@ jobs: java-version: 21 distribution: temurin - - name: Gradle CI + - name: Build OCI Image uses: gradle/gradle-build-action@v2 with: - arguments: build + arguments: clean bootBuildImage --imageName=${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:rc build-root-directory: backend - - name: Build and Push Docker Image - run: | - docker buildx create --use - docker buildx inspect --bootstrap - docker buildx build --platform linux/amd64 --push -t ${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:rc -f ./backend/Dockerfile ./backend + - name: Push OCI Image + run: docker push ${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:rc - name: Logout from Docker Registry run: docker logout ${{ secrets.DOCKER_REGISTRY_URL }} diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 20d7f2416..4b0780a6c 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -25,17 +25,14 @@ jobs: java-version: 21 distribution: temurin - - name: Gradle CI + - name: Build OCI Image uses: gradle/gradle-build-action@v2 with: - arguments: build + arguments: clean bootBuildImage --imageName=${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:release build-root-directory: backend - - name: Build and Push Docker Image - run: | - docker buildx create --use - docker buildx inspect --bootstrap - docker buildx build --platform linux/amd64 --push -t ${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:release -f ./backend/Dockerfile ./backend + - name: Push OCI Image + run: docker push ${{ secrets.DOCKER_REGISTRY_URL }}/cmsch:release - name: Logout from Docker Registry run: docker logout ${{ secrets.DOCKER_REGISTRY_URL }} diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index dba25ac92..cb1d51ae4 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -88,6 +88,16 @@ tasks.withType { } } +tasks.getByName("bootBuildImage") { + builder = "paketobuildpacks/builder-jammy-tiny" + environment = mapOf( + "BP_NATIVE_IMAGE" to "false", + "CDS_TRAINING_JAVA_TOOL_OPTIONS" to "-Dspring.profiles.include=prewarm", + "BP_JVM_CDS_ENABLED" to "true", + "BPL_JVM_THREAD_COUNT" to "25" + ) +} + tasks.withType { useJUnitPlatform() }