use of com.google.cloud.tools.jib.api.ImageReference in project quarkus by quarkusio.
the class JibProcessor method createContainerizer.
private Containerizer createContainerizer(ContainerImageConfig containerImageConfig, JibConfig jibConfig, ContainerImageInfoBuildItem containerImage, boolean pushRequested) {
Containerizer containerizer;
ImageReference imageReference = ImageReference.of(containerImage.getRegistry().orElse(null), containerImage.getRepository(), containerImage.getTag());
if (pushRequested || containerImageConfig.isPushExplicitlyEnabled()) {
if (!containerImageConfig.registry.isPresent()) {
log.info("No container image registry was set, so 'docker.io' will be used");
}
RegistryImage registryImage = toRegistryImage(imageReference, containerImageConfig.username, containerImageConfig.password);
containerizer = Containerizer.to(registryImage);
} else {
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()));
} else {
// detect the container runtime instead of falling back to 'docker' as the default
ContainerRuntimeUtil.ContainerRuntime detectedContainerRuntime = ContainerRuntimeUtil.detectContainerRuntime();
log.infof("Using %s to run the native image builder", detectedContainerRuntime.getExecutableName());
dockerDaemonImage.setDockerExecutable(Paths.get(detectedContainerRuntime.getExecutableName()));
}
containerizer = Containerizer.to(dockerDaemonImage);
}
containerizer.setToolName("Quarkus");
containerizer.setToolVersion(Version.getVersion());
containerizer.addEventHandler(LogEvent.class, (e) -> {
if (!e.getMessage().isEmpty()) {
log.log(toJBossLoggingLevel(e.getLevel()), e.getMessage());
}
});
containerizer.setAllowInsecureRegistries(containerImageConfig.insecure);
containerizer.setAlwaysCacheBaseImage(jibConfig.alwaysCacheBaseImage);
containerizer.setOfflineMode(jibConfig.offlineMode);
return containerizer;
}
Aggregations