Polish "Add network option for image building"
See gh-27486
This commit is contained in:
@@ -155,6 +155,12 @@ Where `<options>` can contain:
|
||||
* `volume-opt=key=value` to specify key-value pairs consisting of an option name and its value
|
||||
|
|
||||
|
||||
| `network`
|
||||
| `--network`
|
||||
| The https://docs.docker.com/network/#network-drivers[network driver] the builder container will be configured to use.
|
||||
The value supplied will be passed unvalidated to Docker when creating the builder container.
|
||||
|
|
||||
|
||||
| `cleanCache`
|
||||
| `--cleanCache`
|
||||
| Whether to clean the cache before building.
|
||||
@@ -170,13 +176,6 @@ Where `<options>` can contain:
|
||||
| Whether to publish the generated image to a Docker registry.
|
||||
| `false`
|
||||
|
||||
| `network`
|
||||
| `--network`
|
||||
| The network the build container will connect to. The value supplied for this option will be passed
|
||||
unvalidated as `HostConfig.NetworkMode` to the configuration which creates the build container,
|
||||
see https://docs.docker.com/engine/api/v1.41/#operation/ContainerCreate[Docker's engine API].
|
||||
Using this option is similar to running `docker build --network ...`.
|
||||
|
|
||||
|===
|
||||
|
||||
NOTE: The plugin detects the target Java compatibility of the project using the JavaPlugin's `targetCompatibility` property.
|
||||
|
||||
@@ -71,6 +71,7 @@ class BootBuildImageIntegrationTests {
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("env: BP_JVM_VERSION=8.*");
|
||||
assertThat(result.getOutput()).contains("Network status: HTTP/2 200");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
removeImage(projectName);
|
||||
}
|
||||
@@ -247,6 +248,20 @@ class BootBuildImageIntegrationTests {
|
||||
removeImage(projectName);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void buildsImageWithNetworkModeNone() throws IOException {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
|
||||
assertThat(result.getOutput()).contains("Network status: curl failed");
|
||||
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
|
||||
removeImage(projectName);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWithBuilderError() throws IOException {
|
||||
writeMainClass();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
if (project.hasProperty('applyWarPlugin')) {
|
||||
apply plugin: 'war'
|
||||
}
|
||||
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
|
||||
bootBuildImage {
|
||||
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"
|
||||
network = "none"
|
||||
}
|
||||
Reference in New Issue
Block a user