use of com.github.dockerjava.api.model.ContainerConfig in project spring-boot by spring-projects.
the class PaketoBuilderTests method executableJarApp.
@Test
void executableJarApp() throws Exception {
writeMainClass();
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
BuildResult result = buildImage(imageName);
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
container.waitingFor(Wait.forHttp("/test")).start();
ContainerConfig config = container.getContainerInfo().getConfig();
assertLabelsMatchManifestAttributes(config);
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
metadata.processOfType("web").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
metadata.processOfType("executable-jar").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
});
assertImageHasSbomLayer(imageReference, config, "executable-jar");
assertImageLayersMatchLayersIndex(imageReference, config);
} finally {
removeImage(imageReference);
}
}
use of com.github.dockerjava.api.model.ContainerConfig in project spring-boot by spring-projects.
the class PaketoBuilderTests method plainDistZipJarApp.
@Test
void plainDistZipJarApp() throws Exception {
writeMainClass();
String projectName = this.gradleBuild.getProjectDir().getName();
String imageName = "paketo-integration/" + projectName;
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
BuildResult result = buildImage(imageName, "assemble", "bootDistZip");
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
container.waitingFor(Wait.forHttp("/test")).start();
ContainerConfig config = container.getContainerInfo().getConfig();
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
metadata.processOfType("web").extracting("command", "args").containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
metadata.processOfType("dist-zip").extracting("command", "args").containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
});
assertImageHasSbomLayer(imageReference, config, "dist-zip");
DigestCapturingCondition digest = new DigestCapturingCondition();
ImageAssertions.assertThat(config).lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(), (layer) -> layer.entries().contains(projectName + "/bin/" + projectName, projectName + "/lib/" + projectName + "-plain.jar").anyMatch((s) -> s.startsWith(projectName + "/lib/spring-boot-")).anyMatch((s) -> s.startsWith(projectName + "/lib/spring-core-")).anyMatch((s) -> s.startsWith(projectName + "/lib/spring-web-")));
} finally {
removeImage(imageReference);
}
}
use of com.github.dockerjava.api.model.ContainerConfig in project spring-boot by spring-projects.
the class PaketoBuilderTests method plainWarApp.
@Test
void plainWarApp() throws Exception {
writeMainClass();
writeServletInitializerClass();
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
BuildResult result = buildImage(imageName);
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
container.waitingFor(Wait.forHttp("/test")).start();
ContainerConfig config = container.getContainerInfo().getConfig();
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/apache-tomcat", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
metadata.processOfType("web").extracting("command", "args").containsExactly("bash", Arrays.asList("catalina.sh", "run"));
metadata.processOfType("tomcat").extracting("command", "args").containsExactly("bash", Arrays.asList("catalina.sh", "run"));
});
assertImageHasSbomLayer(imageReference, config, "apache-tomcat");
DigestCapturingCondition digest = new DigestCapturingCondition();
ImageAssertions.assertThat(config).lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(), (layer) -> layer.entries().contains("WEB-INF/classes/example/ExampleApplication.class", "WEB-INF/classes/example/HelloController.class", "META-INF/MANIFEST.MF").anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-boot-")).anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-core-")).anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-web-")));
} finally {
removeImage(imageReference);
}
}
use of com.github.dockerjava.api.model.ContainerConfig in project spring-boot by spring-projects.
the class PaketoBuilderTests method bootDistZipJarApp.
@Test
void bootDistZipJarApp() throws Exception {
writeMainClass();
String projectName = this.gradleBuild.getProjectDir().getName();
String imageName = "paketo-integration/" + projectName;
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
BuildResult result = buildImage(imageName, "assemble", "bootDistZip");
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
container.waitingFor(Wait.forHttp("/test")).start();
ContainerConfig config = container.getContainerInfo().getConfig();
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
metadata.processOfType("web").extracting("command", "args").containsExactly("/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
metadata.processOfType("dist-zip").extracting("command", "args").containsExactly("/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
});
assertImageHasSbomLayer(imageReference, config, "dist-zip");
DigestCapturingCondition digest = new DigestCapturingCondition();
ImageAssertions.assertThat(config).lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(), (layer) -> layer.entries().contains(projectName + "-boot/bin/" + projectName, projectName + "-boot/lib/" + projectName + ".jar"));
} finally {
removeImage(imageReference);
}
}
use of com.github.dockerjava.api.model.ContainerConfig in project spring-boot by spring-projects.
the class PaketoBuilderTests method executableWarApp.
@Test
void executableWarApp() throws Exception {
writeMainClass();
writeServletInitializerClass();
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
BuildResult result = buildImage(imageName);
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
container.waitingFor(Wait.forHttp("/test")).start();
ContainerConfig config = container.getContainerInfo().getConfig();
assertLabelsMatchManifestAttributes(config);
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
metadata.processOfType("web").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
metadata.processOfType("executable-jar").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
});
assertImageHasSbomLayer(imageReference, config, "executable-jar");
assertImageLayersMatchLayersIndex(imageReference, config);
} finally {
removeImage(imageReference);
}
}
Aggregations