From f3a6f53105a1c56fd00f0d9b3201ebe714455c2e Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Fri, 5 Nov 2021 10:09:38 -0400 Subject: [PATCH 1/9] Change default base images to Eclipse Temurin --- jib-cli/CHANGELOG.md | 1 + .../cloud/tools/jib/cli/jar/JarFiles.java | 6 +-- .../cloud/tools/jib/cli/JibCliTest.java | 5 +- .../cloud/tools/jib/cli/jar/JarFilesTest.java | 12 ++--- .../jib/builder/steps/PullBaseImageStep.java | 6 +-- .../jib/builder/steps/BuildImageStepTest.java | 2 +- jib-gradle-plugin/CHANGELOG.md | 2 + .../jib/gradle/GradleProjectProperties.java | 2 +- jib-maven-plugin/CHANGELOG.md | 2 + .../jib/maven/MavenProjectProperties.java | 2 +- ...mpatibleBaseImageJavaVersionException.java | 2 +- .../common/PluginConfigurationProcessor.java | 14 ++--- .../plugins/common/MainClassResolverTest.java | 6 +-- .../PluginConfigurationProcessorTest.java | 54 ++++++++++++++++--- proposals/buildfile.md | 4 +- proposals/container-build-plan-spec.md | 4 +- 16 files changed, 84 insertions(+), 40 deletions(-) diff --git a/jib-cli/CHANGELOG.md b/jib-cli/CHANGELOG.md index 47ec75290f..d360b24387 100644 --- a/jib-cli/CHANGELOG.md +++ b/jib-cli/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. ### Changed - Downgraded Google HTTP libraries to 1.34.0 to resolve network issues. ([#3415](https://github.com/GoogleContainerTools/jib/pull/3415), [#3058](https://github.com/GoogleContainerTools/jib/issues/3058), [#3409](https://github.com/GoogleContainerTools/jib/issues/3409)) +- Changed the default base image of the Jib CLI `jar` command from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin by Adoptium is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) ### 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 0de58c2f8a..9d42d75629 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 @@ -57,7 +57,7 @@ public static JibContainerBuilder toJibContainerBuilder( ConsoleLogger logger) throws IOException, InvalidImageReferenceException { - // Use AdoptOpenJDK image as the default base image. + // Use Adoptium Temurin image as the default base image. JibContainerBuilder containerBuilder; Optional imageReference = commonContainerConfigCliOptions.getFrom(); if (imageReference.isPresent()) { @@ -68,9 +68,9 @@ public static JibContainerBuilder toJibContainerBuilder( containerBuilder = (processor.getJavaVersion() <= 8) ? ContainerBuilders.create( - "adoptopenjdk:8-jre", Collections.emptySet(), commonCliOptions, logger) + "eclipse-temurin:8-jre", Collections.emptySet(), commonCliOptions, logger) : ContainerBuilders.create( - "adoptopenjdk:11-jre", Collections.emptySet(), commonCliOptions, logger); + "eclipse-temurin:11-jre", Collections.emptySet(), commonCliOptions, logger); } List layers = processor.createLayers(); diff --git a/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java b/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java index aa51776bea..72c78a0614 100644 --- a/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java +++ b/jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java @@ -127,7 +127,8 @@ public void testWriteImageJson() throws InvalidImageReferenceException, IOException, DigestException { String imageId = "sha256:61bb3ec31a47cb730eb58a38bbfa813761a51dca69d10e39c24c3d00a7b2c7a9"; String digest = "sha256:3f1be7e19129edb202c071a659a4db35280ab2bb1a16f223bfd5d1948657b6fc"; - when(mockJibContainer.getTargetImage()).thenReturn(ImageReference.parse("adoptopenjdk:8-jre")); + when(mockJibContainer.getTargetImage()) + .thenReturn(ImageReference.parse("eclipse-temurin:8-jre")); when(mockJibContainer.getImageId()).thenReturn(DescriptorDigest.fromDigest(imageId)); when(mockJibContainer.getDigest()).thenReturn(DescriptorDigest.fromDigest(digest)); when(mockJibContainer.getTags()).thenReturn(ImmutableSet.of("latest", "tag-2")); @@ -138,7 +139,7 @@ public void testWriteImageJson() String outputJson = new String(Files.readAllBytes(outputPath), StandardCharsets.UTF_8); ImageMetadataOutput metadataOutput = JsonTemplateMapper.readJson(outputJson, ImageMetadataOutput.class); - assertThat(metadataOutput.getImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(metadataOutput.getImage()).isEqualTo("eclipse-temurin:8-jre"); assertThat(metadataOutput.getImageId()).isEqualTo(imageId); assertThat(metadataOutput.getImageDigest()).isEqualTo(digest); assertThat(metadataOutput.getTags()).containsExactly("latest", "tag-2"); 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 b1d2838759..3f46775325 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 @@ -78,7 +78,7 @@ public void testToJibContainer_defaultBaseImage_java8() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre"); } @Test @@ -94,7 +94,7 @@ public void testToJibContainer_defaultBaseImage_java9() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:11-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:11-jre"); } @Test @@ -123,7 +123,7 @@ public void testToJibContainerBuilder_explodedStandard_basicInfo() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -172,7 +172,7 @@ public void testToJibContainerBuilder_packagedStandard_basicInfo() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -223,7 +223,7 @@ public void testToJibContainerBuilder_explodedLayeredSpringBoot_basicInfo() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); @@ -272,7 +272,7 @@ public void testToJibContainerBuilder_packagedSpringBoot_basicInfo() mockLogger); ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan(); - assertThat(buildPlan.getBaseImage()).isEqualTo("adoptopenjdk:8-jre"); + assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre"); assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux"))); assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH); assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker); diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java b/jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java index a9c6fa060c..d47fcd2976 100644 --- a/jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java @@ -233,7 +233,7 @@ Optional tryMirrors( progressDispatcher1.newChildProducer().create("trying mirror " + mirror, 2)) { RegistryClient registryClient = buildContext.newBaseImageRegistryClientFactory(mirror).newRegistryClient(); - List images = pullPublicImages(eventHandlers, registryClient, progressDispatcher2); + List images = pullPublicImages(registryClient, progressDispatcher2); eventHandlers.dispatch(LogEvent.info("pulled manifest from mirror " + mirror)); return Optional.of(new ImagesAndRegistryClient(images, registryClient)); @@ -249,9 +249,7 @@ Optional tryMirrors( } private List pullPublicImages( - EventHandlers eventHandlers, - RegistryClient registryClient, - ProgressEventDispatcher progressDispatcher) + RegistryClient registryClient, ProgressEventDispatcher progressDispatcher) throws IOException, RegistryException, LayerCountMismatchException, BadContainerConfigurationFormatException { try { diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/BuildImageStepTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/BuildImageStepTest.java index 38fd2058ce..b996946a0a 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/BuildImageStepTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/BuildImageStepTest.java @@ -146,7 +146,7 @@ public void test_basicCase() { .call(); Assert.assertEquals("root", image.getUser()); Assert.assertEquals( - testDescriptorDigest, image.getLayers().asList().get(0).getBlobDescriptor().getDigest()); + testDescriptorDigest, image.getLayers().get(0).getBlobDescriptor().getDigest()); } @Test diff --git a/jib-gradle-plugin/CHANGELOG.md b/jib-gradle-plugin/CHANGELOG.md index 837d2bc6d0..602f0dfd72 100644 --- a/jib-gradle-plugin/CHANGELOG.md +++ b/jib-gradle-plugin/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file. ### Changed +- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) + ### Fixed - Fixed `ClassCastException` when using non-`String` value (for example, [`Provider`](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html)) for `Main-Class` manifest attribute of the `jar` task. ([#3396](https://github.com/GoogleContainerTools/jib/issues/3396)) diff --git a/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java index 2096617316..377940b743 100644 --- a/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java +++ b/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java @@ -292,7 +292,7 @@ public List getClassFiles() throws IOException { getMainSourceSet().getOutput().getClassesDirs().filter(File::exists); List classFiles = new ArrayList<>(); for (File classesOutputDirectory : classesOutputDirectories) { - classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk().asList()); + classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk()); } return classFiles; } diff --git a/jib-maven-plugin/CHANGELOG.md b/jib-maven-plugin/CHANGELOG.md index 47d0705cea..bc42d1d4a4 100644 --- a/jib-maven-plugin/CHANGELOG.md +++ b/jib-maven-plugin/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file. ### Changed +- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) + ### Fixed ## 3.1.4 diff --git a/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java b/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java index 7158e1e262..7b457951c6 100644 --- a/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java +++ b/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java @@ -356,7 +356,7 @@ Map> classifyDependencies( @Override public List getClassFiles() throws IOException { - return new DirectoryWalker(Paths.get(project.getBuild().getOutputDirectory())).walk().asList(); + return new DirectoryWalker(Paths.get(project.getBuild().getOutputDirectory())).walk(); } @Override diff --git a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java index 2954d2c3c1..a0b8612e48 100644 --- a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java +++ b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/IncompatibleBaseImageJavaVersionException.java @@ -19,7 +19,7 @@ /** * Exception when the Java version in the base image is incompatible with the Java version of the * application to be containerized. For example, when the project is Java 11 but the base image is - * {@code adoptopenjdk:8-jre}. + * Java 8. */ public class IncompatibleBaseImageJavaVersionException extends Exception { diff --git a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java index 73db6ba82a..c7fcb115af 100644 --- a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java +++ b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java @@ -736,8 +736,8 @@ static void writeFileConservatively(Path file, String content) throws IOExceptio /** * Gets the suitable value for the base image. If the raw base image parameter is null, returns - * {@code "jetty"} for WAR projects or {@code "adoptopenjdk:8-jre"} or {@code - * "adoptopenjdk:11-jre"} for non-WAR. + * {@code "jetty"} for WAR projects or {@code "eclipse-temurin:8-jre"} or {@code + * "eclipse-temurin:11-jre"} for non-WAR. * * @param projectProperties used for providing additional information * @return the base image @@ -752,9 +752,9 @@ static String getDefaultBaseImage(ProjectProperties projectProperties) } int javaVersion = projectProperties.getMajorJavaVersion(); if (javaVersion <= 8) { - return "adoptopenjdk:8-jre"; + return "eclipse-temurin:8-jre"; } else if (javaVersion <= 11) { - return "adoptopenjdk:11-jre"; + return "eclipse-temurin:11-jre"; } throw new IncompatibleBaseImageJavaVersionException(11, javaVersion); } @@ -1054,7 +1054,8 @@ private static Path getCheckedCacheDirectory(String property, Path defaultPath) * @return {@code true} if the image is a known Java 8 image */ private static boolean isKnownJava8Image(String imageReference) { - return imageReference.startsWith("adoptopenjdk:8"); + return imageReference.startsWith("adoptopenjdk:8") + || imageReference.startsWith("eclipse-temurin:8"); } /** @@ -1064,6 +1065,7 @@ private static boolean isKnownJava8Image(String imageReference) { * @return {@code true} if the image is a known Java 11 image */ private static boolean isKnownJava11Image(String imageReference) { - return imageReference.startsWith("adoptopenjdk:11"); + return imageReference.startsWith("adoptopenjdk:11") + || imageReference.startsWith("eclipse-temurin:11"); } } diff --git a/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/MainClassResolverTest.java b/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/MainClassResolverTest.java index d94cc41fe1..c5134b099a 100644 --- a/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/MainClassResolverTest.java +++ b/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/MainClassResolverTest.java @@ -92,8 +92,7 @@ public void testResolveMainClass_multipleInferredWithInvalidMainClassFromJarPlug .thenReturn( new DirectoryWalker( Paths.get(Resources.getResource("core/class-finder-tests/multiple").toURI())) - .walk() - .asList()); + .walk()); try { MainClassResolver.resolveMainClass(null, mockProjectProperties); @@ -126,8 +125,7 @@ public void testResolveMainClass_multipleInferredWithoutMainClassFromJarPlugin() .thenReturn( new DirectoryWalker( Paths.get(Resources.getResource("core/class-finder-tests/multiple").toURI())) - .walk() - .asList()); + .walk()); try { MainClassResolver.resolveMainClass(null, mockProjectProperties); Assert.fail(); diff --git a/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java b/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java index 8547a6ce7b..fab314ad7d 100644 --- a/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java +++ b/jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java @@ -846,7 +846,7 @@ public void testGetDefaultBaseImage_nonWarPackaging() when(projectProperties.isWarProject()).thenReturn(false); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:8-jre"); + .isEqualTo("eclipse-temurin:8-jre"); } @Test @@ -863,15 +863,15 @@ public void testGetDefaultBaseImage_chooseJava8BaseImage() throws IncompatibleBaseImageJavaVersionException { when(projectProperties.getMajorJavaVersion()).thenReturn(6); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:8-jre"); + .isEqualTo("eclipse-temurin:8-jre"); when(projectProperties.getMajorJavaVersion()).thenReturn(7); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:8-jre"); + .isEqualTo("eclipse-temurin:8-jre"); when(projectProperties.getMajorJavaVersion()).thenReturn(8); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:8-jre"); + .isEqualTo("eclipse-temurin:8-jre"); } @Test @@ -879,15 +879,15 @@ public void testGetDefaultBaseImage_chooseJava11BaseImage() throws IncompatibleBaseImageJavaVersionException { when(projectProperties.getMajorJavaVersion()).thenReturn(9); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:11-jre"); + .isEqualTo("eclipse-temurin:11-jre"); when(projectProperties.getMajorJavaVersion()).thenReturn(10); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:11-jre"); + .isEqualTo("eclipse-temurin:11-jre"); when(projectProperties.getMajorJavaVersion()).thenReturn(11); assertThat(PluginConfigurationProcessor.getDefaultBaseImage(projectProperties)) - .isEqualTo("adoptopenjdk:11-jre"); + .isEqualTo("eclipse-temurin:11-jre"); } @Test @@ -969,6 +969,26 @@ public void testGetJavaContainerBuilderWithBaseImage_incompatibleJava8BaseImage( rawConfiguration, projectProperties, inferredAuthProvider)); assertThat(exception2.getBaseImageMajorJavaVersion()).isEqualTo(8); assertThat(exception2.getProjectMajorJavaVersion()).isEqualTo(11); + + when(rawConfiguration.getFromImage()).thenReturn(Optional.of("eclipse-temurin:8")); + IncompatibleBaseImageJavaVersionException exception3 = + assertThrows( + IncompatibleBaseImageJavaVersionException.class, + () -> + PluginConfigurationProcessor.getJavaContainerBuilderWithBaseImage( + rawConfiguration, projectProperties, inferredAuthProvider)); + assertThat(exception3.getBaseImageMajorJavaVersion()).isEqualTo(8); + assertThat(exception3.getProjectMajorJavaVersion()).isEqualTo(11); + + when(rawConfiguration.getFromImage()).thenReturn(Optional.of("eclipse-temurin:8-jre")); + IncompatibleBaseImageJavaVersionException exception4 = + assertThrows( + IncompatibleBaseImageJavaVersionException.class, + () -> + PluginConfigurationProcessor.getJavaContainerBuilderWithBaseImage( + rawConfiguration, projectProperties, inferredAuthProvider)); + assertThat(exception4.getBaseImageMajorJavaVersion()).isEqualTo(8); + assertThat(exception4.getProjectMajorJavaVersion()).isEqualTo(11); } @Test @@ -994,6 +1014,26 @@ public void testGetJavaContainerBuilderWithBaseImage_incompatibleJava11BaseImage rawConfiguration, projectProperties, inferredAuthProvider)); assertThat(exception2.getBaseImageMajorJavaVersion()).isEqualTo(11); assertThat(exception2.getProjectMajorJavaVersion()).isEqualTo(15); + + when(rawConfiguration.getFromImage()).thenReturn(Optional.of("eclipse-temurin:11")); + IncompatibleBaseImageJavaVersionException exception3 = + assertThrows( + IncompatibleBaseImageJavaVersionException.class, + () -> + PluginConfigurationProcessor.getJavaContainerBuilderWithBaseImage( + rawConfiguration, projectProperties, inferredAuthProvider)); + assertThat(exception3.getBaseImageMajorJavaVersion()).isEqualTo(11); + assertThat(exception3.getProjectMajorJavaVersion()).isEqualTo(15); + + when(rawConfiguration.getFromImage()).thenReturn(Optional.of("eclipse-temurin:11-jre")); + IncompatibleBaseImageJavaVersionException exception4 = + assertThrows( + IncompatibleBaseImageJavaVersionException.class, + () -> + PluginConfigurationProcessor.getJavaContainerBuilderWithBaseImage( + rawConfiguration, projectProperties, inferredAuthProvider)); + assertThat(exception4.getBaseImageMajorJavaVersion()).isEqualTo(11); + assertThat(exception4.getProjectMajorJavaVersion()).isEqualTo(15); } // https://github.com/GoogleContainerTools/jib/issues/1995 diff --git a/proposals/buildfile.md b/proposals/buildfile.md index de4eaa4559..9ea15eebce 100644 --- a/proposals/buildfile.md +++ b/proposals/buildfile.md @@ -9,7 +9,7 @@ kind: Buildfile # "FROM" with detail for manifest lists or multiple architectures from: - image: "adoptopenjdk:11-jre" + image: "eclipse-temurin:11-jre" # optional: if missing, then defaults to `linux/amd64` platforms: - architecture: "arm" @@ -18,7 +18,7 @@ from: os: darwin # potentially simple form of "FROM" (based on ability to define schema) -from: "adoptopenjdk:11-jre" +from: "eclipse-temurin:11-jre" creationTime: 0 # millis since epoch or iso8601 creation time format: Docker # Docker or OCI diff --git a/proposals/container-build-plan-spec.md b/proposals/container-build-plan-spec.md index 400a807513..4de2934749 100644 --- a/proposals/container-build-plan-spec.md +++ b/proposals/container-build-plan-spec.md @@ -2,13 +2,13 @@ Specification for building a container image. -Although looking similar, the structure and semantics of similary named properties are different from the Docker/[OCI Image Configuration](https://github.com/opencontainers/image-spec/blob/master/config.md). +Although looking similar, the structure and semantics of similarly named properties are different from the Docker/[OCI Image Configuration](https://github.com/opencontainers/image-spec/blob/master/config.md). ## Example ``` { - "baseImage": "adoptopenjdk:11-jre@sha256:318dc2103fb30d0e02c373d04f7c337229268879af9fb3f77f89c6a9037efcb1", + "baseImage": "eclipse-temurin:11-jre@sha256:a3036d6a01859e3fe8cbad4887ccb2e4afd5f5ce8f085ca6bc0302fcbb8601f7", "architectureHint": "amd64", "osHint": "linux", "format": "Docker", From 0e6eb495598db1afd39085471f72de010d5e3375 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Fri, 5 Nov 2021 10:24:43 -0400 Subject: [PATCH 2/9] Update CHANGELOGs --- jib-cli/CHANGELOG.md | 2 +- jib-gradle-plugin/CHANGELOG.md | 2 +- jib-maven-plugin/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jib-cli/CHANGELOG.md b/jib-cli/CHANGELOG.md index d360b24387..9494b74d0a 100644 --- a/jib-cli/CHANGELOG.md +++ b/jib-cli/CHANGELOG.md @@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file. ### Changed - Downgraded Google HTTP libraries to 1.34.0 to resolve network issues. ([#3415](https://github.com/GoogleContainerTools/jib/pull/3415), [#3058](https://github.com/GoogleContainerTools/jib/issues/3058), [#3409](https://github.com/GoogleContainerTools/jib/issues/3409)) -- Changed the default base image of the Jib CLI `jar` command from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin by Adoptium is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) +- Changed the default base image of the Jib CLI `jar` command from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin by Adoptium is the new name of AdoptOpenJDK. ([#3491](https://github.com/GoogleContainerTools/jib/pull/3491)) ### Fixed diff --git a/jib-gradle-plugin/CHANGELOG.md b/jib-gradle-plugin/CHANGELOG.md index 602f0dfd72..2033085149 100644 --- a/jib-gradle-plugin/CHANGELOG.md +++ b/jib-gradle-plugin/CHANGELOG.md @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. ### Changed -- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) +- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#3491](https://github.com/GoogleContainerTools/jib/pull/3491)) ### Fixed diff --git a/jib-maven-plugin/CHANGELOG.md b/jib-maven-plugin/CHANGELOG.md index bc42d1d4a4..d120ce3937 100644 --- a/jib-maven-plugin/CHANGELOG.md +++ b/jib-maven-plugin/CHANGELOG.md @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. ### Changed -- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#xyz](https://github.com/GoogleContainerTools/jib/pull/xyz)) +- Changed the default base image from the `adoptopenjdk` images to the `eclipse-temurin` images on Docker Hub. Note that Temurin (by Adoptium) is the new name of AdoptOpenJDK. ([#3491](https://github.com/GoogleContainerTools/jib/pull/3491)) ### Fixed From 611b631c19b9aba4018ecce8c7592234726306c6 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 9 Nov 2021 10:35:41 -0500 Subject: [PATCH 3/9] Update docs for base image changes --- docs/faq.md | 20 +++++++++++--------- jib-gradle-plugin/README.md | 6 +++--- jib-maven-plugin/README.md | 6 +++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index c77c510958..b6dd9fda52 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -88,9 +88,9 @@ For more information, see [steps 4-6 of the Kubernetes Engine deployment tutoria ### Where is bash? -By default, Jib Maven and Gradle plugin versions prior to 3.0 used [`distroless/java`](https://github.com/GoogleContainerTools/distroless/tree/master/java) as the base image, which did not have a shell program (such as `sh`, `bash`, or `dash`). Starting from Jib build plugins 3.0, the default base image is [`adoptopenjdk`](default_base_image.md) (and [`jetty`](https://hub.docker.com/_/jetty) for WAR projects), which contains shell programs. +By default, Jib Maven and Gradle plugin versions prior to 3.0 used [`distroless/java`](https://github.com/GoogleContainerTools/distroless/tree/master/java) as the base image, which did not have a shell program (such as `sh`, `bash`, or `dash`). However, recent Jib tools use [default base images](default_base_image.md) that come with shell programs: Adoptium Eclipse Temurin (formerly AdoptOpenJDK) for Java 8 and 11, Azul Zulu for Java 17, and Jetty for WAR projects. -Note that you can always set a different base image. Jib's default choice for AdoptOpenJDK does not imply any endorsement to it; you should do your due diligence to choose the right image that works best for you. Also note that the default base image is unpinned (the tag can point to different images over time), so we recommend configuring a base image with a SHA digest for strong reproducibility. +Note that you can always set a different base image. Jib's default choice for Temurin and Zulu does not imply any endorsement to it; you should do your due diligence to choose the right image that works best for you. Also note that the default base image is unpinned (the tag can point to different images over time), so we recommend configuring a base image with a SHA digest for strong reproducibility. * Configuring a base image in Maven ```xml @@ -184,7 +184,7 @@ Jib applications are split into the following layers: ### Which base image (JDK) does Jib use? -[`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. +[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) by Adoptium (formerly [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk)) and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. ### Can I learn more about container images? @@ -461,10 +461,12 @@ jib.to.image = 'gcr.io/my-gcp-project/my-app:' + System.nanoTime() A Dockerfile that performs a Jib-like build is shown below: ```Dockerfile -# Jib uses AdoptOpenJDK as the default base image -FROM adoptopenjdk:11-jre +# Jib uses Adoptium Eclipse Temurin (formerly AdoptOpenJDK) for Java 8 and 11, +# and Azul Zulu for Java 17 as the default base image. +FROM eclipse-temurin:11-jre -# Multiple copy statements are used to break the app into layers, allowing for faster rebuilds after small changes +# Multiple copy statements are used to break the app into layers, +# allowing for faster rebuilds after small changes COPY dependencyJars /app/libs COPY snapshotDependencyJars /app/libs COPY projectDependencyJars /app/libs @@ -569,14 +571,14 @@ The Jib build plugins have an extension framework that enables anyone to easily See the [Maven](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#global-jib-configuration), [Gradle](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#global-jib-configuration) or [Jib CLI](https://github.com/GoogleContainerTools/jib/blob/master/jib-cli/README.md#global-jib-configuration) docs. Note that the example in the docs uses [Google's Docker Hub mirror on `mirror.gcr.io`](https://cloud.google.com/container-registry/docs/pulling-cached-images). -Starting from Jib build plugins 3.0, [the default base image is `adoptopenjdk` and `jetty` on Docker Hub](default_base_image.md), so you may start to encounter the rate limits if you are not explicitly setting a base image. +Starting from Jib build plugins 3.0, Jib by default uses [base images on Docker Hub](default_base_image.md), so you may start to encounter the rate limits if you are not explicitly setting a base image. Some other alternatives to get around the rate limits: * Prevent Jib from accessing Docker Hub (after Jib cached a base image locally). - - **Pin to a specific base image using a SHA digest (for example, `jib.from.image='adoptopenjdk:11-jre@sha256:...'`).** If you are not setting a base image with a SHA digest (which is the case if you don't set `jib.from.image` at all), then every time Jib runs, it reaches out to the registry to check if the base image is up-to-date. On the other hand, if you pin to a specific image with a digest, then the image is immutable. Therefore, if Jib has cached the image once (by running Jib online once to fully cache the image), Jib will not reach out the Docker Hub. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. + - **Pin to a specific base image using a SHA digest (for example, `jib.from.image='eclipse-temurin:11-jre@sha256:...'`).** If you are not setting a base image with a SHA digest (which is the case if you don't set `jib.from.image` at all), then every time Jib runs, it reaches out to the registry to check if the base image is up-to-date. On the other hand, if you pin to a specific image with a digest, then the image is immutable. Therefore, if Jib has cached the image once (by running Jib online once to fully cache the image), Jib will not reach out the Docker Hub. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. - (Maven/Gradle plugins only) **Do offline building.** Pass `--offline` to Maven or Gradle. Before that, you need to run Jib online once to cache the image. However, `--offline` means you cannot push to a remote registry. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. - - **Read a base from a local Docker deamon.** Store an image to your local Docker daemon, and set, say, `jib.from.image='docker://adoptopenjdk:11-jre'`. It can be slow for an initial build where Jib has to cache the image in Jib's format. For performance reasons, we usually recommend using an image on a registry. + - **Read a base from a local Docker deamon.** Store an image to your local Docker daemon, and set, say, `jib.from.image='docker://eclipse-temurin:11-jre'`. It can be slow for an initial build where Jib has to cache the image in Jib's format. For performance reasons, we usually recommend using an image on a registry. - **Set up a local registry, store a base image, and read it from the local registry.** Setting up a local registry is as simple as running `docker run -d -p5000:5000 registry:2`, but nevertheless, the whole process is a bit involved. * Retry with increasing backoffs. For example, using the [`retry`](https://github.com/kadwanev/retry) tool. diff --git a/jib-gradle-plugin/README.md b/jib-gradle-plugin/README.md index b9470949f5..10a30783dc 100644 --- a/jib-gradle-plugin/README.md +++ b/jib-gradle-plugin/README.md @@ -210,7 +210,7 @@ Field | Type | Default | Description Property | Type | Default | Description --- | --- | --- | --- -`image` | `String` | `adoptopenjdk:{8,11}-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). +`image` | `String` | `eclipse-temurin:{8,11}-jre` or `azul/zulu-openjdk:17-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). `auth` | [`auth`](#auth-closure) | *None* | Specifies credentials directly (alternative to `credHelper`). `credHelper` | `String` | *None* | Specifies a credential helper that can authenticate pulling the base image. This parameter can either be configured as an absolute path to the credential helper executable or as a credential helper suffix (following `docker-credential-`). `platforms` | [`platforms`](#platforms-closure) | See [`platforms`](#platforms-closure) | _Incubating feature_: Configures platforms of base images to select from a manifest list. @@ -393,8 +393,8 @@ There are three different types of base images that Jib accepts: an image from a Prefix | Example | Type --- | --- | --- -*None* | `adoptopenjdk:11-jre` | Pulls the base image from a registry. -`registry://` | `registry://adoptopenjdk:11-jre` | Pulls the base image from a registry. +*None* | `openjdk:11-jre` | Pulls the base image from a registry. +`registry://` | `registry://eclipse-temurin:11-jre` | Pulls the base image from a registry. `docker://` | `docker://busybox` | Retrieves the base image from the Docker daemon. `tar://` | `tar:///path/to/file.tar` | Uses an image tarball stored at the specified path as the base image. Also accepts relative paths (e.g. `tar://build/jib-image.tar`). diff --git a/jib-maven-plugin/README.md b/jib-maven-plugin/README.md index c98badc425..0f1aeef7a4 100644 --- a/jib-maven-plugin/README.md +++ b/jib-maven-plugin/README.md @@ -260,7 +260,7 @@ Field | Type | Default | Description Property | Type | Default | Description --- | --- | --- | --- -`image` | string | `adoptopenjdk:{8,11}-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). +`image` | string | `temurin-eclipse:{8,11}-jre` or `azul/zulu-openjdk:17-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). `auth` | [`auth`](#auth-object) | *None* | Specifies credentials directly (alternative to `credHelper`). `credHelper` | string | *None* | Specifies a credential helper that can authenticate pulling the base image. This parameter can either be configured as an absolute path to the credential helper executable or as a credential helper suffix (following `docker-credential-`). `platforms` | list | See [`platform`](#platform-object) | _Incubating feature_: Configures platforms of base images to select from a manifest list. @@ -460,8 +460,8 @@ There are three different types of base images that Jib accepts: an image from a Prefix | Example | Type --- | --- | --- -*None* | `adoptopenjdk:11-jre` | Pulls the base image from a registry. -`registry://` | `registry://adoptopenjdk:11-jre` | Pulls the base image from a registry. +*None* | `openjdk:11-jre` | Pulls the base image from a registry. +`registry://` | `registry://eclipse-temurin:11-jre` | Pulls the base image from a registry. `docker://` | `docker://busybox` | Retrieves the base image from the Docker daemon. `tar://` | `tar:///path/to/file.tar` | Uses an image tarball stored at the specified path as the base image. Also accepts relative paths (e.g. `tar://target/jib-image.tar`). From ce849e39d2fc0520c294334dc168e2ca3d2ecfb5 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 9 Nov 2021 18:10:22 -0500 Subject: [PATCH 4/9] Update docs for 3.2 release --- docs/default_base_image.md | 12 +++++++----- docs/faq.md | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/default_base_image.md b/docs/default_base_image.md index 06c6d92de0..f16056d83f 100644 --- a/docs/default_base_image.md +++ b/docs/default_base_image.md @@ -1,12 +1,14 @@ # Default Base Images in Jib -## Jib Build Plugins 3.0 +## Jib Build Plugins 3+ -Starting from version 3.0, the default base image is the official [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) image on Docker Hub. AdoptOpenJDK (which is [being renamed to Adoptium](https://blog.adoptopenjdk.net/2020/06/adoptopenjdk-to-join-the-eclipse-foundation/)) is a popular OpenJDK build also used by [Google Cloud Buildpacks](https://github.com/GoogleCloudPlatform/buildpacks) (for Java) by default. +Starting from version 3.2, the default is the official [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. Note that Eclipse Temurin by Adoptium is the [successor of AdoptOpenJDK](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/) and Azul Systems is a founding member of the Adoptium Working Group. + +For versions 3.0 and 3.1, the default base image is the official [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) image on Docker Hub. For WAR projects, the default is the official [`jetty`](https://hub.docker.com/_/jetty) image on Docker Hub. -Note that Jib's default choice for AdoptOpenJDK and Jetty does not imply any endorsement to them. In fact, for strong reproducibility (which also results in better performance and efficiency), we always recommend configuring [`jib.from.image`](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#from-closure) (Gradle) or [``](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#from-object) (Maven) to pin to a specific base image using a digest (or at least a tag). And while doing so, you should do your due diligence to figure out which base image will work best for you. +Note that Jib's default choice for Temurin, Zulu, AdoptOpenJDK, and Jetty does not imply any endorsement to them. In fact, for strong reproducibility (which also results in better performance and efficiency), we always recommend configuring [`jib.from.image`](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#from-closure) (Gradle) or [``](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#from-object) (Maven) to pin to a specific base image using a digest (or at least a tag). And while doing so, you should do your due diligence to figure out which base image will work best for you. ### Docker Hub Download Rate Limit @@ -28,7 +30,7 @@ Note that, even after Jib fully cached a base image, Jib still connects to Docke Some options: * Configure a registry mirror. * Prevent Jib from accessing Docker Hub (after Jib cached a base image locally). - - Pin to a specific base image using a SHA digest (for example, `jib.from.image='adoptopenjdk:11-jre@sha256:...'`). + - Pin to a specific base image using a SHA digest (for example, `jib.from.image='eclipse-temurin:11-jre@sha256:...'`). - Do offline building. - Read a base from a local Docker deamon. - Set up a local registry, store a base image, and read it from the local registry. @@ -81,4 +83,4 @@ For some reason if you have to keep the exact same behavior when using 3.0, you ## Jib CLI -The JAR mode of the Jib CLI has always used AdoptOpenJDK and the WAR mode uses `jetty`. +For the JAR mode, old versions of Jib CLI has always used AdoptOpenJDK. Newer versions use [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. The WAR mode uses `jetty`. diff --git a/docs/faq.md b/docs/faq.md index b6dd9fda52..50eb32e208 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -184,7 +184,7 @@ Jib applications are split into the following layers: ### Which base image (JDK) does Jib use? -[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) by Adoptium (formerly [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk)) and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. +[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) by Adoptium (formerly [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk)) for Java 8 and 11, [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk`) for Java 17, and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. ### Can I learn more about container images? From e6e94760b0e5ff6297b217f5cf2a1d5812ca531a Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 9 Nov 2021 18:13:41 -0500 Subject: [PATCH 5/9] Update doc --- docs/default_base_image.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/default_base_image.md b/docs/default_base_image.md index f16056d83f..eb00337a67 100644 --- a/docs/default_base_image.md +++ b/docs/default_base_image.md @@ -2,7 +2,7 @@ ## Jib Build Plugins 3+ -Starting from version 3.2, the default is the official [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. Note that Eclipse Temurin by Adoptium is the [successor of AdoptOpenJDK](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/) and Azul Systems is a founding member of the Adoptium Working Group. +Starting from version 3.2, the default is the official [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. Note that Eclipse Temurin by Adoptium is the [successor of AdoptOpenJDK](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/) and Azul Systems is a [founding member](https://www.azul.com/blog/eclipse-temurin-new-distribution-of-openjdk/) of the Adoptium Working Group. For versions 3.0 and 3.1, the default base image is the official [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) image on Docker Hub. From 56f57e5bd66caa3cd973e97a779cce1d1239143c Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 9 Nov 2021 18:28:27 -0500 Subject: [PATCH 6/9] Update doc --- docs/faq.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 50eb32e208..1ef298f05e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -576,9 +576,9 @@ Starting from Jib build plugins 3.0, Jib by default uses [base images on Docker Some other alternatives to get around the rate limits: * Prevent Jib from accessing Docker Hub (after Jib cached a base image locally). - - **Pin to a specific base image using a SHA digest (for example, `jib.from.image='eclipse-temurin:11-jre@sha256:...'`).** If you are not setting a base image with a SHA digest (which is the case if you don't set `jib.from.image` at all), then every time Jib runs, it reaches out to the registry to check if the base image is up-to-date. On the other hand, if you pin to a specific image with a digest, then the image is immutable. Therefore, if Jib has cached the image once (by running Jib online once to fully cache the image), Jib will not reach out the Docker Hub. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. + - **Pin to a specific base image using a SHA digest.** For example, `jib.from.image='eclipse-temurin:11-jre@sha256:...'`. If you are not setting a base image with a SHA digest (which is the case if you don't set `jib.from.image` at all), then every time Jib runs, it reaches out to the registry to check if the base image is up-to-date. On the other hand, if you pin to a specific image with a digest, then the image is immutable. Therefore, if Jib has cached the image once (by running Jib online once to fully cache the image), Jib will not reach out to the Docker Hub. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. - (Maven/Gradle plugins only) **Do offline building.** Pass `--offline` to Maven or Gradle. Before that, you need to run Jib online once to cache the image. However, `--offline` means you cannot push to a remote registry. See [this Stack Overflow answer](https://stackoverflow.com/a/61190005/1701388) for more details. - - **Read a base from a local Docker deamon.** Store an image to your local Docker daemon, and set, say, `jib.from.image='docker://eclipse-temurin:11-jre'`. It can be slow for an initial build where Jib has to cache the image in Jib's format. For performance reasons, we usually recommend using an image on a registry. + - **Retrieve a base image from a local Docker deamon.** Store an image to your local Docker daemon, and set, say, `jib.from.image='docker://eclipse-temurin:11-jre'`. It can be slow for an initial build where Jib has to cache the image in Jib's format. For performance reasons, we usually recommend using an image on a registry. - **Set up a local registry, store a base image, and read it from the local registry.** Setting up a local registry is as simple as running `docker run -d -p5000:5000 registry:2`, but nevertheless, the whole process is a bit involved. * Retry with increasing backoffs. For example, using the [`retry`](https://github.com/kadwanev/retry) tool. From 406e1b0d1f0393d5647a9c2c5ff690538feff411 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Fri, 12 Nov 2021 17:10:38 -0500 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cd888d39b..577db74470 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ The [examples](examples) directory includes the following examples (and more). ## How Jib Works -Whereas traditionally a Java application is built as a single image layer with the application JAR, Jib's build strategy separates the Java application into multiple layers for more granular incremental builds. When you change your code, only your changes are rebuilt, not your entire application. These layers, by default, are layered on top of the [AdoptOpenJDK](https://hub.docker.com/_/adoptopenjdk) base image, but you can also configure a custom base image. For more information, check out the [official blog post](https://cloudplatform.googleblog.com/2018/07/introducing-jib-build-java-docker-images-better.html) or watch [this talk](https://www.youtube.com/watch?v=H6gR_Cv4yWI) ([slides](https://speakerdeck.com/coollog/build-containers-faster-with-jib-a-google-image-build-tool-for-java-applications)). +Whereas traditionally a Java application is built as a single image layer with the application JAR, Jib's build strategy separates the Java application into multiple layers for more granular incremental builds. When you change your code, only your changes are rebuilt, not your entire application. These layers, by default, are layered on top of an [OpenJDK base image](docs/default_base_image.md), but you can also configure a custom base image. For more information, check out the [official blog post](https://cloudplatform.googleblog.com/2018/07/introducing-jib-build-java-docker-images-better.html) or watch [this talk](https://www.youtube.com/watch?v=H6gR_Cv4yWI) ([slides](https://speakerdeck.com/coollog/build-containers-faster-with-jib-a-google-image-build-tool-for-java-applications)). See also [rules_docker](https://github.com/bazelbuild/rules_docker) for a similar existing container image build tool for the [Bazel build system](https://github.com/bazelbuild/bazel). From e2edd3f7dc47d2c77145522524c61acfdfe9de86 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 30 Nov 2021 12:06:26 -0500 Subject: [PATCH 8/9] Update default_base_image.md --- docs/default_base_image.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/default_base_image.md b/docs/default_base_image.md index eb00337a67..db0f695e59 100644 --- a/docs/default_base_image.md +++ b/docs/default_base_image.md @@ -83,4 +83,4 @@ For some reason if you have to keep the exact same behavior when using 3.0, you ## Jib CLI -For the JAR mode, old versions of Jib CLI has always used AdoptOpenJDK. Newer versions use [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. The WAR mode uses `jetty`. +For the JAR mode, Jib CLI versions prior to 0.8 have always used AdoptOpenJDK. Starting with 0.8, the tool uses [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. The WAR mode uses `jetty`. From 0d83a116a24977cdba8d5c92d786b2f2aabed543 Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Wed, 19 Jan 2022 10:44:49 -0500 Subject: [PATCH 9/9] Update docs --- docs/default_base_image.md | 8 +++----- docs/faq.md | 9 ++++----- jib-gradle-plugin/README.md | 2 +- jib-maven-plugin/README.md | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/default_base_image.md b/docs/default_base_image.md index db0f695e59..e9ad55b97b 100644 --- a/docs/default_base_image.md +++ b/docs/default_base_image.md @@ -2,13 +2,11 @@ ## Jib Build Plugins 3+ -Starting from version 3.2, the default is the official [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. Note that Eclipse Temurin by Adoptium is the [successor of AdoptOpenJDK](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/) and Azul Systems is a [founding member](https://www.azul.com/blog/eclipse-temurin-new-distribution-of-openjdk/) of the Adoptium Working Group. - -For versions 3.0 and 3.1, the default base image is the official [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) image on Docker Hub. +Starting from version 3.2, the default base image is the official [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) image on Docker Hub. Note that Eclipse Temurin by Adoptium is the [successor of AdoptOpenJDK](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/). (For versions 3.0 and 3.1, the default is the official [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk) image.) For WAR projects, the default is the official [`jetty`](https://hub.docker.com/_/jetty) image on Docker Hub. -Note that Jib's default choice for Temurin, Zulu, AdoptOpenJDK, and Jetty does not imply any endorsement to them. In fact, for strong reproducibility (which also results in better performance and efficiency), we always recommend configuring [`jib.from.image`](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#from-closure) (Gradle) or [``](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#from-object) (Maven) to pin to a specific base image using a digest (or at least a tag). And while doing so, you should do your due diligence to figure out which base image will work best for you. +Note that Jib's default choice for Temurin, AdoptOpenJDK, and Jetty does not imply any endorsement to them. In fact, for strong reproducibility (which also results in better performance and efficiency), we always recommend configuring [`jib.from.image`](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#from-closure) (Gradle) or [``](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#from-object) (Maven) to pin to a specific base image using a digest (or at least a tag). And while doing so, you should do your due diligence to figure out which base image will work best for you. ### Docker Hub Download Rate Limit @@ -83,4 +81,4 @@ For some reason if you have to keep the exact same behavior when using 3.0, you ## Jib CLI -For the JAR mode, Jib CLI versions prior to 0.8 have always used AdoptOpenJDK. Starting with 0.8, the tool uses [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) for Java 8 and 11, and [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk) for Java 17. The WAR mode uses `jetty`. +For the JAR mode, Jib CLI versions prior to 0.8 have always used AdoptOpenJDK. Starting with 0.8, the tool uses [`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin). The WAR mode uses `jetty`. diff --git a/docs/faq.md b/docs/faq.md index a236505e63..1450fbea49 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -89,9 +89,9 @@ For more information, see [steps 4-6 of the Kubernetes Engine deployment tutoria ### Where is bash? -By default, Jib Maven and Gradle plugin versions prior to 3.0 used [`distroless/java`](https://github.com/GoogleContainerTools/distroless/tree/master/java) as the base image, which did not have a shell program (such as `sh`, `bash`, or `dash`). However, recent Jib tools use [default base images](default_base_image.md) that come with shell programs: Adoptium Eclipse Temurin (formerly AdoptOpenJDK) for Java 8 and 11, Azul Zulu for Java 17, and Jetty for WAR projects. +By default, Jib Maven and Gradle plugin versions prior to 3.0 used [`distroless/java`](https://github.com/GoogleContainerTools/distroless/tree/master/java) as the base image, which did not have a shell program (such as `sh`, `bash`, or `dash`). However, recent Jib tools use [default base images](default_base_image.md) that come with shell programs: Adoptium Eclipse Temurin (formerly AdoptOpenJDK) and Jetty for WAR projects. -Note that you can always set a different base image. Jib's default choice for Temurin and Zulu does not imply any endorsement to it; you should do your due diligence to choose the right image that works best for you. Also note that the default base image is unpinned (the tag can point to different images over time), so we recommend configuring a base image with a SHA digest for strong reproducibility. +Note that you can always set a different base image. Jib's default choice for Temurin or AdoptOpenJDK does not imply any endorsement to it; you should do your due diligence to choose the right image that works best for you. Also note that the default base image is unpinned (the tag can point to different images over time), so we recommend configuring a base image with a SHA digest for strong reproducibility. * Configuring a base image in Maven ```xml @@ -185,7 +185,7 @@ Jib applications are split into the following layers: ### Which base image (JDK) does Jib use? -[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) by Adoptium (formerly [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk)) for Java 8 and 11, [`azul/zulu-openjdk`](https://hub.docker.com/r/azul/zulu-openjdk`) for Java 17, and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. +[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin) by Adoptium (formerly [`adoptopenjdk`](https://hub.docker.com/_/adoptopenjdk)) and [`jetty`](https://hub.docker.com/_/jetty) (for WAR). See [Default Base Images in Jib](default_base_image.md) for details. ### Can I learn more about container images? @@ -465,8 +465,7 @@ jib.to.image = 'gcr.io/my-gcp-project/my-app:' + System.nanoTime() A Dockerfile that performs a Jib-like build is shown below: ```Dockerfile -# Jib uses Adoptium Eclipse Temurin (formerly AdoptOpenJDK) for Java 8 and 11, -# and Azul Zulu for Java 17 as the default base image. +# Jib uses Adoptium Eclipse Temurin (formerly AdoptOpenJDK). FROM eclipse-temurin:11-jre # Multiple copy statements are used to break the app into layers, diff --git a/jib-gradle-plugin/README.md b/jib-gradle-plugin/README.md index f59c93d4e1..5e5e902231 100644 --- a/jib-gradle-plugin/README.md +++ b/jib-gradle-plugin/README.md @@ -211,7 +211,7 @@ Field | Type | Default | Description Property | Type | Default | Description --- | --- | --- | --- -`image` | `String` | `eclipse-temurin:{8,11}-jre` or `azul/zulu-openjdk:17-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). +`image` | `String` | `eclipse-temurin:{8,11,17}-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). `auth` | [`auth`](#auth-closure) | *None* | Specifies credentials directly (alternative to `credHelper`). `credHelper` | `String` | *None* | Specifies a credential helper that can authenticate pulling the base image. This parameter can either be configured as an absolute path to the credential helper executable or as a credential helper suffix (following `docker-credential-`). `platforms` | [`platforms`](#platforms-closure) | See [`platforms`](#platforms-closure) | Configures platforms of base images to select from a manifest list. diff --git a/jib-maven-plugin/README.md b/jib-maven-plugin/README.md index a6655e2d30..c15d069d65 100644 --- a/jib-maven-plugin/README.md +++ b/jib-maven-plugin/README.md @@ -261,7 +261,7 @@ Field | Type | Default | Description Property | Type | Default | Description --- | --- | --- | --- -`image` | string | `temurin-eclipse:{8,11}-jre` or `azul/zulu-openjdk:17-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). +`image` | string | `temurin-eclipse:{8,11,17}-jre` (or `jetty` for WAR) | The image reference for the base image. The source type can be specified using a [special type prefix](#setting-the-base-image). `auth` | [`auth`](#auth-object) | *None* | Specifies credentials directly (alternative to `credHelper`). `credHelper` | string | *None* | Specifies a credential helper that can authenticate pulling the base image. This parameter can either be configured as an absolute path to the credential helper executable or as a credential helper suffix (following `docker-credential-`). `platforms` | list | See [`platform`](#platform-object) | Configures platforms of base images to select from a manifest list.