Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request and discussion: support of annotations #332

Closed
Tracked by #454
favonia opened this issue Sep 11, 2023 · 4 comments · Fixed by #352
Closed
Tracked by #454

Feature request and discussion: support of annotations #332

favonia opened this issue Sep 11, 2023 · 4 comments · Fixed by #352

Comments

@favonia
Copy link
Contributor

favonia commented Sep 11, 2023

Assuming that docker/build-push-action#958 will be implemented, I hope annotations can be as well-supported as labels. That is, I wish in the JSON output would somehow contain one of the two values: either (for manifests)

org.opencontainers.image.created=...
org.opencontainers.image.description=...
org.opencontainers.image.licenses=...
org.opencontainers.image.revision=...
org.opencontainers.image.source=...
org.opencontainers.image.title=...
org.opencontainers.image.url=...
org.opencontainers.image.version=...

or (for indexes)

index:org.opencontainers.image.created=...
index:org.opencontainers.image.description=...
index:org.opencontainers.image.licenses=...
index:org.opencontainers.image.revision=...
index:org.opencontainers.image.source=...
index:org.opencontainers.image.title=...
index:org.opencontainers.image.url=...
index:org.opencontainers.image.version=...

However, I soon realized it is not easy to coherently extend the current UI to achieve this:

  1. Annotations can go anywhere, and for multi-arch images (arguably the most common use of indexes), at least ghcr.io specified that the annotations should go to the index. I'm not sure about other hosting services. Theoretically they can go anywhere.
  2. Buildkit will fail if there isn't an index for it to attach index annotations.
  3. It is not easy to predict whether Buildkit would generate an index; see Action started to push manifest indexes instead of images for a single platform build-push-action#755

Despite the above point 3, it seems one reasonable design is:

  • A new option to tell metadata-action to generate those standard annotations for the index or the manifests (or maybe somewhere else?).
  • Another new option annotations for the user to add or overwrite annotations.

I don't want to claim this is a very good design because of the above points 2 and 3. The user will have to know whether there would be an index layer to pick the correct options. On the other hand, it doesn't seem to make things worse, and I'd like to start this conversation now because the automatic metadata generation is arguably the last piece of a smooth pipeline on GitHub.

@crazy-max
Copy link
Member

Opened docker/build-push-action#992 to add support for the new --annotation flag (see also upstream docker/buildx#2020).

Would just need to do smth like https://github.com/docker/build-push-action/pull/992/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR1174

But then we need to set the proper prefix to each "labels" either on the manifest or index. I'm working to make this possible with the metadata-action.

@kroese
Copy link

kroese commented Nov 30, 2023

So how does it work with index:?

I am currently doing:

labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.labels }}

But that won't work if I need to prepend index: to each entry? Is there an easy way to do this?

Is there a flag that you can set if you want them to be added to both?

@favonia
Copy link
Contributor Author

favonia commented Nov 30, 2023

@kroese It's already documented in README. However, I did feel the current README could help the users more and thus opened a PR #359. It still requires you to read through the documentation, though.

@kroese
Copy link

kroese commented Nov 30, 2023

@favonia Sorry, I missed that, you are right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants