Spring Boot 2.3.0 buildpack 构建镜像,创建日期为 40 年前

Ale*_*hin 14 java maven buildpack spring-boot

我尝试在运行 Spring Boot 2.3.0 的 maven 项目中使用 buildpack:

mvn spring-boot:build-image
Run Code Online (Sandbox Code Playgroud)

图像创建得很好,但我看到了以下信息:

REPOSITORY                                    TAG                     IMAGE ID            CREATED             SIZE
gcr.io/paketo-buildpacks/builder              base-platform-api-0.3   daceb4f909b7        40 years ago        690MB
myimage                                       master                  a482a4a34379        40 years ago        285MB
Run Code Online (Sandbox Code Playgroud)

为什么说图像(连同构建器)是 40 年前创建的?

cod*_*ger 7

这是预期的。为了创建可重现的构建(即,可以重复使用层),构建包必须创建具有固定时间戳的层。否则,您将无法重复使用您在之前构建中创建的图层,因为它们具有不同的时间戳。

  • 这绝非“预期”。构建者似乎无法弄清楚如何创建有效的哈希值,而是采用了虚假的时间戳。 (5认同)
  • 虽然其他工具确实也提供此选项,但它们当然也提供使用当前时间的选项,因为这是大多数人所期望的。当开箱即用地使用 Quarkus(使用 jib)时,我们会得到预期的当前时间戳。在 Spring Boot 中用 jib 替换 docker builder 时,我们可以将创建时间设置为 USE_CURRENT_TIMESTAMP 并得到期望的结果。在 buildpack 中也支持这一点怎么样? (4认同)
  • 层不是基于哈希重用吗?我真的不明白它与时间戳有什么关系以及为什么无法指定真正的时间戳。您能详细说明一下吗? (3认同)

koz*_*a13 5

新版本中可以设置。Hier是gradle的例子

bootBuildImage {
      imageName = "docker.io/ringo"
      createdDate = "now"
}
Run Code Online (Sandbox Code Playgroud)

  • 仅在新的 3.1.0 RC 1 版本中 https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.1.0-RC1-Release-Notes (2认同)