-
Notifications
You must be signed in to change notification settings - Fork 127
Refactor bootBuildImage support #11635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
id("com.gorylenko.gradle-git-properties") | ||
id("docker-conventions") | ||
id("java-conventions") | ||
id("org.cyclonedx.bom") | ||
id("org.graalvm.buildtools.native") | ||
id("org.springframework.boot") | ||
} | ||
|
||
|
@@ -18,19 +20,32 @@ | |
|
||
tasks.register("run") { dependsOn(tasks.bootRun) } | ||
|
||
val imagePlatform: String by project | ||
val platform = imagePlatform.ifBlank { null } | ||
|
||
tasks.bootBuildImage { | ||
val env = System.getenv() | ||
val repo = env.getOrDefault("GITHUB_REPOSITORY", "hiero-ledger/hiero-mirror-node") | ||
val image = "ghcr.io/${repo}" | ||
val image = "ghcr.io/${repo}/${project.name}" | ||
|
||
buildpacks = | ||
listOf( | ||
"urn:cnb:builder:paketo-buildpacks/java", | ||
"paketobuildpacks/health-checker", | ||
"paketo-buildpacks/native-image", | ||
) | ||
docker { | ||
imageName = image | ||
tags = listOf("${image}:${project.version}") | ||
publishRegistry { token = env["GITHUB_TOKEN"] } | ||
imagePlatform = platform | ||
publishRegistry { | ||
password = env.getOrDefault("GITHUB_TOKEN", "") | ||
username = env.getOrDefault("GITHUB_ACTOR", "") | ||
} | ||
tags = listOf("${image}:${project.version}2") | ||
} | ||
|
||
environment = | ||
mapOf( | ||
"BP_HEALTH_CHECKER_ENABLED" to "true", | ||
"BP_NATIVE_IMAGE_BUILD_ARGUMENTS" to | ||
"--initialize-at-build-time=org.slf4j.helpers.Reporter,org.slf4j.LoggerFactory,ch.qos.logback", | ||
"BP_OCI_AUTHORS" to "[email protected]", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
common/src/main/java/org/hiero/mirror/common/config/CommonRuntimeHints.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.hiero.mirror.common.config; | ||
|
||
import com.github.benmanes.caffeine.cache.AsyncCacheLoader; | ||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import org.springframework.aot.hint.ExecutableMode; | ||
import org.springframework.aot.hint.MemberCategory; | ||
import org.springframework.aot.hint.RuntimeHints; | ||
import org.springframework.aot.hint.RuntimeHintsRegistrar; | ||
import org.springframework.aot.hint.TypeReference; | ||
|
||
public class CommonRuntimeHints implements RuntimeHintsRegistrar { | ||
@Override | ||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { | ||
// Caffeine loads generated cache implementations via reflection | ||
registerCache(hints, "SSMSA"); | ||
registerCache(hints, "SSR"); | ||
registerCache(hints, "SSSMA"); | ||
registerCache(hints, "SSSMSA"); | ||
registerCache(hints, "SSSW"); | ||
registerNode(hints, "PSAMS"); | ||
registerNode(hints, "PSR"); | ||
|
||
// For ReconciliationJob.timestampStart use as an ID in Hibernate | ||
hints.reflection().registerType(TypeReference.of(Instant[].class), MemberCategory.UNSAFE_ALLOCATED); | ||
} | ||
|
||
private void registerCache(RuntimeHints hints, String className) { | ||
final var types = List.of( | ||
TypeReference.of(Caffeine.class), | ||
TypeReference.of(AsyncCacheLoader.class), | ||
TypeReference.of("boolean")); | ||
hints.reflection() | ||
.registerType( | ||
TypeReference.of("com.github.benmanes.caffeine.cache." + className), | ||
Check warning on line 38 in common/src/main/java/org/hiero/mirror/common/config/CommonRuntimeHints.java
|
||
b -> b.withConstructor(types, ExecutableMode.INVOKE)); | ||
} | ||
|
||
private void registerNode(RuntimeHints hints, String className) { | ||
hints.reflection() | ||
.registerType( | ||
TypeReference.of("com.github.benmanes.caffeine.cache." + className), | ||
b -> b.withConstructor(List.of(), ExecutableMode.INVOKE)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.