To maintain parity with pack
, metadata for the ephemeral builder container should:
- Include a structure in the container metadata field
Config.Labels["io.buildpacks.builder.metadata"]
that identifies Spring Boot as the creator along with the Boot version:
"createdBy" : {
"name" : "Spring Boot",
"version" : "2.3.0.BUILD-SNAPSHOT"
}
- Set the container creation date to
1980-01-01T00:00:01Z
(Windows epoch + 1 second)
Comment From: snicoll
@scottfrederick I built an image this morning with the latest snapshot and this is what docker images
shows for it:
snicoll78/demo-image latest 24e14746abe3 40 years ago
I don't know where the miss-date is coming from but I think this is something we should be looking at.
Comment From: snicoll
I've cleaned containers and images to see if that would make any difference and building an image leads to:
snicoll78/demo-image latest 6e0b588f44ae 40 years ago 241MB
cloudfoundry/cnb 0.0.53-bionic 2420741eabb3 40 years ago 738MB
Comment From: wilkinsona
The date is intentional:
Set the container creation date to 1980-01-01T00:00:01Z (Windows epoch + 1 second)
It's to align with the behaviour of pack
. However, looking at the pack
code, I've only been able to spot it normalising the date and time for the contents of the tar archive from which the image is created and not the image itself. I may well have missed something though.
@snicoll can you confirm what pack
does?
Comment From: snicoll
pack
does indeed create an image with a similar created
date:
cloudfoundry/cnb 0.0.53-bionic 2420741eabb3 40 years ago 738MB
cloudfoundry/cnb bionic 2420741eabb3 40 years ago 738MB
snicoll78/demo-image-pack latest 6e0b588f44ae 40 years ago 241MB
snicoll78/demo-image latest 6e0b588f44ae 40 years ago 241MB
snicoll78/demo-image-pack
was built with the regular pack
command.
Comment From: scottfrederick
Documenting the rationale behind this for future reference:
CNB and pack
use this fixed date for all images to optimize build reproducibility. Given the same set of inputs (application bits, builder, buildpacks, etc), two builds should generate identical images down to the image digest (which takes into account all image metadata including Created
date and time).
There is an ongoing discussion about making this fixed date/time configurable so users can choose the value and provide a better UX than 40 years ago
: https://github.com/buildpacks/rfcs/pull/50.
Comment From: HoffiMuc
is there a way to specify the image creation time via spring-boot gradle plugin? did not find anything on it anywhere
Comment From: scottfrederick
It is currently not possible to specify an image creation timestamp with the Spring Boot build plugins. This matches the behavior of the pack
CLI to ensure reproducible builds.
If you have a use case for configuring a different fixed timestamp, open a new issue and we'll consider it for a future release.