nlewo / nix2container

An archive-less dockerTools.buildImage implementation
Apache License 2.0
512 stars 45 forks source link

Support annotations #124

Open aaronmondal opened 6 months ago

aaronmondal commented 6 months ago

Annotations in the OCI spec may be used to add additional information to an image: https://github.com/opencontainers/image-spec/blob/main/annotations.md

We recently migrated from the builtin dockerTools to nix2container (https://github.com/TraceMachina/nativelink/commit/1a43ef91c8587b5c4708643f1593968286586f01). Just now did I notice that our annotations are no longer visible in the github actions tab.

Before migration:

https://github.com/TraceMachina/nativelink/pkgs/container/nativelink/192735920?tag=2bqf910c8d2g5b0l4gmrifq1xbvxfdmg

After migration:

https://github.com/TraceMachina/nativelink/pkgs/container/nativelink/193042543?tag=symgcw9plncfbp18vizjhzl8nfknbkgr

It looks like the config.Labels section behaves slightly differently between the two.

dockerTools adds the labels to the manifest, visible with docker manifest inspect someimage, while nix2container adds it to the Config section in the output of docker image inspect someimage.

AFAIU the behavior of dockerTools is actually incorrect as the annotations shouldn't live in config but in a separate annotations field instead: https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest-property-descriptions

Would it be possible/sensible to add an annotations field to buildImage and friends?

nlewo commented 6 months ago

Hello @aaronmondal ,

Would it be possible/sensible to add an annotations field to buildImage and friends?

Such kind of contributions would be welcomed (i've not planned to implement it soon).