From d5aa9bb7fe7263e2401f7911a7c4bf874392ae71 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:36:15 -0500 Subject: [PATCH] Use adoptopenjdk base image instead of openjdk in the Jib CLI (#3108) * Use adoptopenjdk base image instead of openjdk * Update CHANGELOG --- jib-cli/CHANGELOG.md | 1 + .../com/google/cloud/tools/jib/cli/jar/JarFiles.java | 4 ++-- .../google/cloud/tools/jib/cli/jar/JarFilesTest.java | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/jib-cli/CHANGELOG.md b/jib-cli/CHANGELOG.md index eaf00d114d..2785b70403 100644 --- a/jib-cli/CHANGELOG.md +++ b/jib-cli/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Added ### Changed +- Changed the default base image of the Jib CLI jar command from the `openjdk` images to the `adoptopenjdk` images on Docker Hub. ([#3108](https://github.com/GoogleContainerTools/jib/pull/3108])) ### Fixed diff --git a/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java b/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java index 5d96d33d8a..c2e85d2ff6 100644 --- a/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java +++ b/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java @@ -59,8 +59,8 @@ public static JibContainerBuilder toJibContainerBuilder( } else { containerBuilder = (processor.getJarJavaVersion() <= 8) - ? Jib.from("openjdk:8-jre-slim") - : Jib.from("openjdk:11-jre-slim"); + ? Jib.from("adoptopenjdk:8-jre") + : Jib.from("adoptopenjdk:11-jre"); } List layers = processor.createLayers(); diff --git a/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java b/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java index d2a54f0505..c6ac100ae6 100644 --- a/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java +++ b/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java @@ -71,7 +71,7 @@ public void testToJibContainer_defaultBaseImage_java8() mockStandardExplodedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:8-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); } @Test @@ -83,7 +83,7 @@ public void testToJibContainer_defaultBaseImage_java9() mockStandardExplodedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:11-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:11-jre"); } @Test @@ -108,7 +108,7 @@ public void testToJibContainerBuilder_explodedStandard_basicInfo() mockStandardExplodedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:8-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -153,7 +153,7 @@ public void testToJibContainerBuilder_packagedStandard_basicInfo() mockStandardPackagedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:8-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -199,7 +199,7 @@ public void testToJibContainerBuilder_explodedLayeredSpringBoot_basicInfo() mockSpringBootExplodedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:8-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -244,7 +244,7 @@ public void testToJibContainerBuilder_packagedSpringBoot_basicInfo() mockSpringBootPackagedProcessor, mockJarCommand, mockCommonCliOptions, mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("openjdk:8-jre-slim"); + assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker);