From bbd18a61c57e62ca93113416d7451fa093de4915 Mon Sep 17 00:00:00 2001 From: James Kennedy Date: Mon, 16 Dec 2024 11:58:06 -0800 Subject: [PATCH] Replace netty with Apache httpclient --- .../build/extractor/docker/DockerJavaWrapper.java | 12 +++++++++--- .../docker/extractor/DockerExtractorTest.java | 1 + build.gradle | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/DockerJavaWrapper.java b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/DockerJavaWrapper.java index 62acae273..aa7ea154e 100644 --- a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/DockerJavaWrapper.java +++ b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/DockerJavaWrapper.java @@ -4,13 +4,14 @@ import com.github.dockerjava.api.command.BuildImageCmd; import com.github.dockerjava.api.command.InspectImageResponse; import com.github.dockerjava.api.model.AuthConfig; -import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DockerClientBuilder; import com.github.dockerjava.core.DockerClientConfig; +import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.command.BuildImageResultCallback; import com.github.dockerjava.core.command.PullImageResultCallback; import com.github.dockerjava.core.command.PushImageResultCallback; -import com.github.dockerjava.netty.NettyDockerCmdExecFactory; +import com.github.dockerjava.httpclient5.ApacheDockerHttpClient; +import com.github.dockerjava.transport.DockerHttpClient; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.jfrog.build.api.util.Log; @@ -74,7 +75,12 @@ public static DockerClient getDockerClient(String host, Map envV } DockerClientConfig config = configBuilder.build(); - return DockerClientBuilder.getInstance(config).withDockerCmdExecFactory(new NettyDockerCmdExecFactory()).build(); + + DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder() + .dockerHost(config.getDockerHost()) + .sslConfig(config.getSSLConfig()) + .build(); + return DockerClientBuilder.getInstance(config).withDockerHttpClient(httpClient).build(); } /** diff --git a/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java b/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java index 8591345c3..58b3501e7 100644 --- a/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java +++ b/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java @@ -10,6 +10,7 @@ import org.jfrog.build.api.multiMap.ListMultimap; import org.jfrog.build.api.multiMap.Multimap; import org.jfrog.build.extractor.ci.*; +import org.jfrog.build.extractor.ci.Module; import org.jfrog.build.extractor.docker.DockerJavaWrapper; import org.jfrog.build.extractor.executor.CommandExecutor; import org.jfrog.build.extractor.executor.CommandResults; diff --git a/build.gradle b/build.gradle index 8ab75ceab..d25ba6549 100644 --- a/build.gradle +++ b/build.gradle @@ -472,6 +472,7 @@ project('build-info-extractor-docker') { implementation(group: 'com.github.docker-java', name: 'docker-java', version: dockerJavaVersion) { exclude group: 'org.glassfish.jersey.core', module: 'jersey-common' } + implementation group: 'com.github.docker-java', name: 'docker-java-transport-httpclient5', version: dockerJavaVersion implementation group: 'org.glassfish.jersey.core', name: 'jersey-common', version: jerseyVersion } }