Skip to content

Commit

Permalink
Make docker executable configurable when using Jib
Browse files Browse the repository at this point in the history
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: quarkusio#21677
  • Loading branch information
geoand committed Nov 25, 2021
1 parent dac1d1e commit 8053f50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> dockerExecutableName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> dockerConfigExecutableName = ConfigProvider.getConfig()
.getOptionalValue("quarkus.docker.executable-name", String.class);
Optional<String> 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());
Expand Down

0 comments on commit 8053f50

Please sign in to comment.