Add bindings option for image building
This commit adds configuration to the Maven and Gradle plugins to allow a list of volume mount bindings to be provided to the image building goal and task. This enables service bindings to be mounted in the builder image that are recognized by buildpacks to support custom certificates, build tool configuration, APM integration, and other buildpack features. Fixes gh-23518
This commit is contained in:
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.buildpack.platform.build.BuildRequest;
|
||||
import org.springframework.boot.buildpack.platform.build.BuildpackReference;
|
||||
import org.springframework.boot.buildpack.platform.build.PullPolicy;
|
||||
import org.springframework.boot.buildpack.platform.docker.type.Binding;
|
||||
import org.springframework.boot.buildpack.platform.io.Owner;
|
||||
import org.springframework.boot.buildpack.platform.io.TarArchive;
|
||||
|
||||
@@ -68,6 +69,7 @@ class ImageTests {
|
||||
assertThat(request.isVerboseLogging()).isFalse();
|
||||
assertThat(request.getPullPolicy()).isEqualTo(PullPolicy.ALWAYS);
|
||||
assertThat(request.getBuildpacks()).isEmpty();
|
||||
assertThat(request.getBindings()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,6 +137,15 @@ class ImageTests {
|
||||
BuildpackReference.of("example/buildpack2@0.0.2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBuildRequestWhenHasBindingsUsesBindings() {
|
||||
Image image = new Image();
|
||||
image.bindings = Arrays.asList("host-src:container-dest:ro", "volume-name:container-dest:rw");
|
||||
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
|
||||
assertThat(request.getBindings()).containsExactly(Binding.of("host-src:container-dest:ro"),
|
||||
Binding.of("volume-name:container-dest:rw"));
|
||||
}
|
||||
|
||||
private Artifact createArtifact() {
|
||||
return new DefaultArtifact("com.example", "my-app", VersionRange.createFromVersion("0.0.1-SNAPSHOT"), "compile",
|
||||
"jar", null, new DefaultArtifactHandler());
|
||||
|
||||
Reference in New Issue
Block a user