bazel-contrib / rules_oci

Bazel rules for building OCI containers
Apache License 2.0
305 stars 159 forks source link

Introduce new attribute on `oci_image` for `created` datetime #724

Closed hanneskaeufler closed 3 weeks ago

hanneskaeufler commented 1 month ago

Fixes #661 . Alternative to #722.

Why?

Doing a docker inspect --format='{{.Created}}' my/image:latest on an image built with oci_image previously always returned the static beginning of the unix timestamp (1. January 1970 00:00:00). To be more precise, that's what it returns for images that are built "from scratch". When an image is built on a base, then the created date is set to the created date of the base image.

Both are fine strategies for reproducible builds, but in stamped builds that are eventually shipped/deployed, you probably want to set that time to the actual build time.

What?

To allow setting that particular Created in the manifest json, we introduce a separate file label, allowing to pass in a file containing a stamp variable.

hanneskaeufler commented 1 month ago

@alexeagle @thesayyn ping in case you haven't seen it. If you'll allow the CI to run I'll make sure to pass that :) Thanks for your time!

thesayyn commented 1 month ago

Oh did not mean that you should rename it, we should use the created property as that's what the OCI spec says.

hanneskaeufler commented 1 month ago

Oh did not mean that you should rename it, we should use the created property as that's what the OCI spec says.

Sorry I don't follow. I feel created_at as an attribute here in rules_oci is indeed the better choice. In the json manifest of course I still keep created https://github.com/bazel-contrib/rules_oci/pull/724/files#diff-4d907c3439c162250ee007024daf813b7354ab62d3a510f68955ca9751d33618R173.

Let me know if that clears it up :) Thanks!

thesayyn commented 1 month ago

Let me know if that clears it up :) Thanks!

the name of the attribute should be identical to config property. so both of them should be created. i was merely suggesting that OCI spec should have named it differently but there is nothing we can do now :)

hanneskaeufler commented 4 weeks ago

some concerns on e2e, otherwise lgtm

Pushed everything I have now, should pass CI as well :) Thx again!

thesayyn commented 3 weeks ago

@hanneskaeufler could you rebase?

hanneskaeufler commented 3 weeks ago

@thesayyn sure can, done ✅