diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 50ce737be08f3..b852e7c784e64 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -213,7 +213,7 @@ 0.15.0 9.41.1 0.9.6 - 0.0.6 + 0.0.12 0.1.3 2.12.1 0.8.11 diff --git a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackConfig.java b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackConfig.java index d5ff64ec4c910..645d3260a9ff0 100644 --- a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackConfig.java +++ b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackConfig.java @@ -14,15 +14,21 @@ public class BuildpackConfig { /** * The buildpacks builder image to use when building the project in jvm mode. */ - @ConfigItem - public Optional jvmBuilderImage; + @ConfigItem(defaultValue = "paketocommunity/builder-ubi-base:latest") + public String jvmBuilderImage; /** - * The buildpacks builder image to use when building the project in jvm mode. + * The buildpacks builder image to use when building the project in native mode. */ @ConfigItem public Optional nativeBuilderImage; + /** + * Should the builder image be 'trusted' (use creator lifecycle) + */ + @ConfigItem + public Optional trustBuilderImage; + /** * Environment key/values to pass to buildpacks. */ @@ -39,16 +45,29 @@ public class BuildpackConfig { public Optional runImage; /** - * Max pull timeout for builder/run images, in seconds + * Initial pull timeout for builder/run images, in seconds */ @ConfigItem(defaultValue = "300") public Integer pullTimeoutSeconds; + /** + * Increase pull timeout for builder/run images after failure, in seconds + */ + @ConfigItem(defaultValue = "15") + public Integer pullTimeoutIncreaseSeconds; + + /** + * How many times to retry an image pull after a failure + */ + @ConfigItem(defaultValue = "3") + public Integer pullRetryCount; + /** * DOCKER_HOST value to use. * - * If not set, the env var DOCKER_HOST is used, if that is not set - * the value `unix:///var/run/docker.sock' (or 'npipe:///./pipe/docker_engine' for windows) is used. + * If not set, the env var DOCKER_HOST is used, if that is not set the platform will look for + * 'npipe:///./pipe/docker_engine' for windows, and `unix:///var/run/docker.sock' then + * `unix:///var/run/podman.sock` then `unix:///var/run/user//podman/podman.sock` for linux */ @ConfigItem public Optional dockerHost; diff --git a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java index b40283807e712..9efe801b87995 100644 --- a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java +++ b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java @@ -18,8 +18,9 @@ import com.github.dockerjava.api.model.AuthConfig; import com.github.dockerjava.api.model.PushResponseItem; -import dev.snowdrop.buildpack.Buildpack; -import dev.snowdrop.buildpack.BuildpackBuilder; +import dev.snowdrop.buildpack.BuildConfig; +import dev.snowdrop.buildpack.BuildConfigBuilder; +import dev.snowdrop.buildpack.config.ImageReference; import dev.snowdrop.buildpack.docker.DockerClientUtils; import io.quarkus.container.image.deployment.ContainerImageConfig; import io.quarkus.container.image.deployment.util.NativeBinaryUtil; @@ -181,33 +182,49 @@ private String runBuildpackBuild(BuildpackConfig buildpackConfig, if (buildContainerImage) { log.info("Initiating Buildpack build"); - Buildpack buildpack = Buildpack.builder() - .addNewFileContent(dirs.get(ProjectDirs.ROOT).toFile()) - .withFinalImage(targetImageName) + int exitCode = BuildConfig.builder() + .addNewFileContentApplication(dirs.get(ProjectDirs.ROOT).toFile()) + .withOutputImage(new ImageReference(targetImageName)) + .withNewPlatformConfig() .withEnvironment(envMap) + .endPlatformConfig() + .withNewLogConfig() + .withLogger(new BuildpackLogger()) .withLogLevel(buildpackConfig.logLevel) + .endLogConfig() + .withNewDockerConfig() + .withPullRetryIncreaseSeconds(buildpackConfig.pullTimeoutIncreaseSeconds) .withPullTimeoutSeconds(buildpackConfig.pullTimeoutSeconds) - .withLogger(new BuildpackLogger()) - .accept(BuildpackBuilder.class, b -> { - + .withPullRetryCount(buildpackConfig.pullRetryCount) + .endDockerConfig() + .accept(BuildConfigBuilder.class, b -> { if (isNativeBuild) { - buildpackConfig.nativeBuilderImage.ifPresent(i -> b.withBuilderImage(i)); + buildpackConfig.nativeBuilderImage.ifPresent(i -> b.withBuilderImage(new ImageReference(i))); } else { - buildpackConfig.jvmBuilderImage.ifPresent(i -> b.withBuilderImage(i)); + b.withBuilderImage(new ImageReference(buildpackConfig.jvmBuilderImage)); } if (buildpackConfig.runImage.isPresent()) { log.info("Using Run image of " + buildpackConfig.runImage.get()); - b.withRunImage(buildpackConfig.runImage.get()); + b.withRunImage(new ImageReference(buildpackConfig.runImage.get())); } + if (buildpackConfig.dockerHost.isPresent()) { log.info("Using DockerHost of " + buildpackConfig.dockerHost.get()); - b.withDockerHost(buildpackConfig.dockerHost.get()); + b.editDockerConfig().withDockerHost(buildpackConfig.dockerHost.get()) + .endDockerConfig(); } - }).build(); + if (buildpackConfig.trustBuilderImage.isPresent()) { + log.info("Setting trusted image to " + buildpackConfig.trustBuilderImage.get()); + b.editPlatformConfig().withTrustBuilder(buildpackConfig.trustBuilderImage.get()) + .endPlatformConfig(); + } + }) + .build() + .getExitCode(); - if (buildpack.getExitCode() != 0) { + if (exitCode != 0) { throw new IllegalStateException("Buildpack build failed"); }