use of org.springframework.boot.buildpack.platform.docker.type.ImageReference in project spring-boot by spring-projects.
the class BootBuildImageRegistryIntegrationTests method buildsImageAndPublishesToRegistry.
@TestTemplate
void buildsImageAndPublishesToRegistry() throws IOException {
writeMainClass();
String repoName = "test-image";
String imageName = this.registryAddress + "/" + repoName;
BuildResult result = this.gradleBuild.build("bootBuildImage", "--imageName=" + imageName);
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("Building image").contains("Successfully built image").contains("Pushing image '" + imageName + ":latest" + "'").contains("Pushed image '" + imageName + ":latest" + "'");
ImageReference imageReference = ImageReference.of(imageName);
Image pulledImage = new DockerApi().image().pull(imageReference, UpdateListener.none());
assertThat(pulledImage).isNotNull();
new DockerApi().image().remove(imageReference, false);
}
use of org.springframework.boot.buildpack.platform.docker.type.ImageReference in project spring-boot by spring-projects.
the class ImageBuildpackTests method resolveReferenceWithDigestUsesDigest.
@Test
void resolveReferenceWithDigestUsesDigest() throws Exception {
Image image = Image.of(getContent("buildpack-image.json"));
String digest = "sha256:4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30";
ImageReference imageReference = ImageReference.of("example/buildpack1@" + digest);
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
given(resolverContext.fetchImage(eq(imageReference), eq(ImageType.BUILDPACK))).willReturn(image);
willAnswer(this::withMockLayers).given(resolverContext).exportImageLayers(eq(imageReference), any());
BuildpackReference reference = BuildpackReference.of("example/buildpack1@" + digest);
Buildpack buildpack = ImageBuildpack.resolve(resolverContext, reference);
assertThat(buildpack.getCoordinates()).hasToString("example/hello-universe@0.0.1");
assertHasExpectedLayers(buildpack);
}
use of org.springframework.boot.buildpack.platform.docker.type.ImageReference in project spring-boot by spring-projects.
the class ImageBuildpackTests method resolveWhenFullyQualifiedReferenceReturnsBuilder.
@Test
void resolveWhenFullyQualifiedReferenceReturnsBuilder() throws Exception {
Image image = Image.of(getContent("buildpack-image.json"));
ImageReference imageReference = ImageReference.of("example/buildpack1:1.0.0");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
given(resolverContext.fetchImage(eq(imageReference), eq(ImageType.BUILDPACK))).willReturn(image);
willAnswer(this::withMockLayers).given(resolverContext).exportImageLayers(eq(imageReference), any());
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1:1.0.0");
Buildpack buildpack = ImageBuildpack.resolve(resolverContext, reference);
assertThat(buildpack.getCoordinates()).hasToString("example/hello-universe@0.0.1");
assertHasExpectedLayers(buildpack);
}
use of org.springframework.boot.buildpack.platform.docker.type.ImageReference in project spring-boot by spring-projects.
the class BuildImageRegistryIntegrationTests method whenBuildImageIsInvokedWithPublish.
@TestTemplate
void whenBuildImageIsInvokedWithPublish(MavenBuild mavenBuild) {
String repoName = "test-image";
String imageName = this.registryAddress + "/" + repoName;
mavenBuild.project("build-image-publish").goals("package").systemProperty("spring-boot.build-image.imageName", imageName).execute((project) -> {
assertThat(buildLog(project)).contains("Building image").contains("Successfully built image").contains("Pushing image '" + imageName + ":latest" + "'").contains("Pushed image '" + imageName + ":latest" + "'");
ImageReference imageReference = ImageReference.of(imageName);
DockerApi.ImageApi imageApi = new DockerApi().image();
Image pulledImage = imageApi.pull(imageReference, UpdateListener.none());
assertThat(pulledImage).isNotNull();
imageApi.remove(imageReference, false);
});
}
use of org.springframework.boot.buildpack.platform.docker.type.ImageReference in project spring-boot by spring-projects.
the class Builder method tagImage.
private void tagImage(ImageReference sourceReference, List<ImageReference> tags) throws IOException {
for (ImageReference tag : tags) {
this.docker.image().tag(sourceReference, tag);
this.log.taggedImage(tag);
}
}
Aggregations