From 8053f504b7e8f409de5cd434bec1b35a08c5b4b3 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 25 Nov 2021 11:10:30 +0200 Subject: [PATCH] Make docker executable configurable when using Jib When Jib builds a container locally (as opposed to pushing to a registry), it needs a docker executable to perform the build. With this change, the name of that executable is now configurable using either `quarkus.jib.docker-executable-name` or `quarkus.docker.executable-name` Resolves: #21677 --- .../container/image/jib/deployment/JibConfig.java | 7 +++++++ .../container/image/jib/deployment/JibProcessor.java | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java index 8ffa9ce8b0e42..23e4fabb07033 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java @@ -162,4 +162,11 @@ public class JibConfig { */ @ConfigItem(defaultValue = "false") public boolean offlineMode; + + /** + * Name of binary used to execute the docker commands. This is only used by Jib + * when the container image is being built locally. + */ + @ConfigItem + public Optional dockerExecutableName; } diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java index ab11cca3cf94c..631fb799bb175 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java @@ -24,6 +24,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.logging.Logger; import com.google.cloud.tools.jib.api.Containerizer; @@ -210,7 +211,16 @@ private Containerizer createContainerizer(ContainerImageConfig containerImageCon containerImageConfig.password); containerizer = Containerizer.to(registryImage); } else { - containerizer = Containerizer.to(DockerDaemonImage.named(imageReference)); + DockerDaemonImage dockerDaemonImage = DockerDaemonImage.named(imageReference); + Optional dockerConfigExecutableName = ConfigProvider.getConfig() + .getOptionalValue("quarkus.docker.executable-name", String.class); + Optional jibConfigExecutableName = jibConfig.dockerExecutableName; + if (jibConfigExecutableName.isPresent()) { + dockerDaemonImage.setDockerExecutable(Paths.get(jibConfigExecutableName.get())); + } else if (dockerConfigExecutableName.isPresent()) { + dockerDaemonImage.setDockerExecutable(Paths.get(dockerConfigExecutableName.get())); + } + containerizer = Containerizer.to(dockerDaemonImage); } containerizer.setToolName("Quarkus"); containerizer.setToolVersion(Version.getVersion());