Skip to content

Commit

Permalink
Use Spring Boots way of building optimized images
Browse files Browse the repository at this point in the history
  • Loading branch information
Isti01 committed Nov 7, 2024
1 parent a9f215c commit 9cc9b81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
11 changes: 4 additions & 7 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
10 changes: 10 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ tasks.withType<KotlinCompile> {
}
}

tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootBuildImage>("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<Test> {
useJUnitPlatform()
}

0 comments on commit 9cc9b81

Please sign in to comment.