Skip to content

Commit b0a2844

Browse files
committed
Draft jib/native build
1 parent d3e0207 commit b0a2844

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", vers
8383
kmpNativeCoroutines = { id = "com.rickclephas.kmp.nativecoroutines", version.ref = "kmpNativeCoroutines" }
8484
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
8585
kotlinJvm = { id = "org.jetbrains.kotlin.jvm" }
86+
graalvm = { id = "org.graalvm.buildtools.native", version = "0.11.0" }
8687
shadowPlugin = { id = "com.gradleup.shadow", version.ref = "shadowPlugin" }
8788
jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" }
8889

mcp-server/build.gradle.kts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
alias(libs.plugins.shadowPlugin)
77
alias(libs.plugins.jib)
88
application
9-
id("org.graalvm.buildtools.native") version "0.11.0"
9+
alias(libs.plugins.graalvm)
1010
}
1111

1212
dependencies {
@@ -40,22 +40,37 @@ graalvmNative {
4040
vendor.set(JvmVendorSpec.GRAAL_VM)
4141
nativeImageCapable.set(true)
4242
})
43+
buildArgs("--enable-url-protocols=http,https")
4344
}
4445
named("main") {
4546
imageName.set("climate-trace-mcp")
46-
mainClass.set("MainKt")
47+
mainClass.set("McpServerKt")
4748
}
4849
}
4950
}
5051

5152
jib {
52-
from.image = "docker.io/library/eclipse-temurin:21"
53+
from.image = "docker.io/library/alpine:3.22"
5354

5455
to {
5556
image = "gcr.io/climatetrace-mcp/climatetrace-mcp-server"
5657
}
5758
container {
5859
ports = listOf("8080")
59-
mainClass = "McpServerKt"
60+
entrypoint = listOf("/climate-trace-mcp")
6061
}
62+
extraDirectories {
63+
paths {
64+
path {
65+
// copies a single-file.xml
66+
setFrom("build/native/nativeCompile")
67+
into = "/"
68+
includes = listOf("climate-trace-mcp")
69+
}
70+
}
71+
}
72+
}
73+
74+
tasks.named("jib").configure {
75+
dependsOn(tasks.named("nativeCompile"))
6176
}

0 commit comments

Comments
 (0)