Add option to use configured Docker host in builder

This commit adds support for a `docker.bindHostToBuilder` option in
the Maven and Gradle image building goal and task.

Fixes gh-29384
This commit is contained in:
Scott Frederick
2022-03-11 15:27:22 -06:00
parent 93622d18eb
commit 7ad538cd84
24 changed files with 621 additions and 236 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,8 @@ public class DockerSpec {
private String certPath;
private boolean bindHostToBuilder;
private final DockerRegistrySpec builderRegistry;
private final DockerRegistrySpec publishRegistry;
@@ -85,6 +87,16 @@ public class DockerSpec {
this.certPath = certPath;
}
@Input
@Optional
public Boolean isBindHostToBuilder() {
return this.bindHostToBuilder;
}
public void setBindHostToBuilder(boolean use) {
this.bindHostToBuilder = use;
}
/**
* Returns the {@link DockerRegistrySpec} that configures authentication to the
* builder registry.
@@ -150,6 +162,7 @@ public class DockerSpec {
DockerConfiguration asDockerConfiguration() {
DockerConfiguration dockerConfiguration = new DockerConfiguration();
dockerConfiguration = customizeHost(dockerConfiguration);
dockerConfiguration = dockerConfiguration.withBindHostToBuilder(this.bindHostToBuilder);
dockerConfiguration = customizeBuilderAuthentication(dockerConfiguration);
dockerConfiguration = customizePublishAuthentication(dockerConfiguration);
return dockerConfiguration;