Skip to content
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

Making sure the right RocksDB native binary is added for container build #2794

Merged
merged 1 commit into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/kafka-streams/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-client-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-streams</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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")));
cescoffier marked this conversation as resolved.
Show resolved Hide resolved
}

// re-initializing RocksDB to enable load of native libs
reinitialized.produce(new RuntimeReinitializedClassBuildItem("org.rocksdb.RocksDB"));
Expand All @@ -53,4 +60,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;
}
}