diff --git a/extensions/kafka-streams/deployment/pom.xml b/extensions/kafka-streams/deployment/pom.xml index e13d762d978eb..2250e79fc79c6 100644 --- a/extensions/kafka-streams/deployment/pom.xml +++ b/extensions/kafka-streams/deployment/pom.xml @@ -34,6 +34,10 @@ io.quarkus quarkus-core-deployment + + io.quarkus + quarkus-kafka-client-deployment + io.quarkus quarkus-kafka-streams diff --git a/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java b/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java index 0bde6d29b1630..84cd672d276b1 100644 --- a/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java +++ b/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java @@ -56,7 +56,14 @@ void build(RecorderContext recorder, reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, false, ByteArraySerde.class)); reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, false, FailOnInvalidTimestamp.class)); - nativeLibs.produce(new SubstrateResourceBuildItem(Environment.getJniLibraryFileName("rocksdb"))); + // for RocksDB, either add linux64 native lib when targeting containers + if (isContainerBuild()) { + nativeLibs.produce(new SubstrateResourceBuildItem("librocksdbjni-linux64.so")); + } + // otherwise the native lib of the platform this build runs on + else { + nativeLibs.produce(new SubstrateResourceBuildItem(Environment.getJniLibraryFileName("rocksdb"))); + } // re-initializing RocksDB to enable load of native libs reinitialized.produce(new RuntimeReinitializedClassBuildItem("org.rocksdb.RocksDB")); @@ -69,4 +76,22 @@ void build(KafkaStreamsTemplate template) { // static initializers which already ran during build template.loadRocksDb(); } + + private boolean isContainerBuild() { + String containerRuntime = System.getProperty("native-image.container-runtime"); + + if (containerRuntime != null) { + containerRuntime = containerRuntime.trim().toLowerCase(); + return containerRuntime.equals("docker") || containerRuntime.equals("podman"); + } + + String dockerBuild = System.getProperty("native-image.docker-build"); + + if (dockerBuild != null) { + dockerBuild = dockerBuild.trim().toLowerCase(); + return !"false".equals(dockerBuild); + } + + return false; + } }