Skip to content

Commit 134bfcb

Browse files
authored
feat(build): use chainguard jre:latest-dev base image for docker healthcheck support (#882)
Resolves #784, supercedes #811.
1 parent 4675cce commit 134bfcb

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

build.gradle.kts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ plugins {
2727
id("com.github.ben-manes.versions") version "0.52.0"
2828
id("org.jmailen.kotlinter") version "5.2.0"
2929
id("com.google.cloud.tools.jib") version "3.4.5"
30-
id("com.github.johnrengelman.shadow") version "8.1.1"
3130
id("com.vanniktech.maven.publish") version "0.34.0"
3231
id("org.jetbrains.dokka") version "2.0.0"
3332
`java-library`
@@ -206,18 +205,17 @@ jib {
206205
os = "linux"
207206
}
208207
}
209-
image = "gcr.io/distroless/java21-debian12"
208+
image = "cgr.dev/chainguard/jre:latest-dev"
210209
}
211210
container {
212211
ports = listOf("8080")
213212
mainClass = mainClassKt
213+
jvmFlags = listOf(
214+
"--sun-misc-unsafe-memory-access=allow", // see https://netty.io/wiki/java-24-and-sun.misc.unsafe.html
215+
)
214216
}
215217
}
216218

217-
(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
218-
skip()
219-
}
220-
221219
fun isNonStable(version: String): Boolean {
222220
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
223221
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
@@ -248,27 +246,11 @@ tasks {
248246
dependsOn("formatKotlin")
249247
}
250248

251-
withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
252-
archiveBaseName.set("app")
253-
archiveClassifier.set("")
254-
manifest {
255-
attributes(
256-
mapOf(
257-
"Main-Class" to mainClassKt
258-
)
259-
)
260-
}
261-
}
262-
263249
withType<Test> {
264250
jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
265251
useJUnitPlatform()
266252
}
267253

268-
"jibDockerBuild" {
269-
dependsOn("shadowJar")
270-
}
271-
272254
withType<Wrapper> {
273255
gradleVersion = "8.14.1"
274256
}

docker-compose-ssl.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.1"
2-
31
services:
42
mock-oauth2-server:
53
image: mock-oauth2-server:latest
@@ -11,3 +9,9 @@ services:
119
LOG_LEVEL: "debug"
1210
SERVER_PORT: 8080
1311
JSON_CONFIG_PATH: /app/config.json
12+
healthcheck:
13+
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/isalive" ]
14+
start_period: 5s
15+
retries: 10
16+
interval: 2s
17+
timeout: 1s

docker-compose.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.1"
2-
31
services:
42
mock-oauth2-server:
53
image: mock-oauth2-server:latest
@@ -13,3 +11,9 @@ services:
1311
LOG_LEVEL: "debug"
1412
SERVER_PORT: 8080
1513
JSON_CONFIG_PATH: /app/config.json
14+
healthcheck:
15+
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/isalive" ]
16+
start_period: 5s
17+
retries: 10
18+
interval: 2s
19+
timeout: 1s

0 commit comments

Comments
 (0)