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

Add OCI annotations to docker images #1542

Closed
mikaello opened this issue May 11, 2023 · 4 comments · Fixed by #1545
Closed

Add OCI annotations to docker images #1542

mikaello opened this issue May 11, 2023 · 4 comments · Fixed by #1545
Labels
👶 good first issue Good for newcomers 🐋 docker Related to Docker code 🍩 enhancement New feature or request 👋 help wanted Help wanted!

Comments

@mikaello
Copy link
Contributor

It would have been nice if the Kroki docker image built in this project used the OCI annotations, these can be used by other tools to enhance the user experience. E.g. Renovate will use the source label to add a link back to where the image is coming from.

Currently, there are no labels for the kroki image:

$ docker inspect yuzutech/kroki:0.20.0 --format '{{ json .Config.Labels }}'
null

This could be done be adding the OCI labels directly into the Dockerfile, or by using the docker/metadata-action, but that is maybe difficult since you are building the images inside a Makefile?

@ggrossetie
Copy link
Member

Behind the scene we are using docker buildx bake which supports labels: https://docs.docker.com/build/bake/reference/#targetlabels

It would be useful if you could suggest a list of labels (key and value) that we should set.

@mikaello
Copy link
Contributor Author

Sure!

The one I find most useful is org.opencontainers.image.source, which can be used to provide a reference back to this repository. But it could be nice some of the others as well:

LABEL \
    org.opencontainers.image.title="Kroki" \
    org.opencontainers.image.description="Kroki provides a unified API supporting multiple diagramming formats, making it easy to create diagrams from textual descriptions." \
    org.opencontainers.image.url="https://kroki.io" \
    org.opencontainers.image.source="https://github.com/yuzutech/kroki" \
    org.opencontainers.image.licenses="MIT"

But you maybe want to use the labels map field in docker-bake.hcl?

@ggrossetie
Copy link
Member

Thanks!

But you maybe want to use the labels map field in docker-bake.hcl?

Is there a best practice or a recommended way to define labels?
Since the values are "static" (i.e., do not depend on the context/release) I would say it's fine to define them in the Dockerfile.

Are you willing to submit a pull request?

@ggrossetie ggrossetie added 🍩 enhancement New feature or request 👋 help wanted Help wanted! 👶 good first issue Good for newcomers 🐋 docker Related to Docker code labels May 14, 2023
mikaello added a commit to mikaello/kroki that referenced this issue May 15, 2023
@mikaello
Copy link
Contributor Author

Is there a best practice or a recommended way to define labels?

I'm not sure, the docker bake file was new to me, I am only used to pure Dockerfiles.

Are you willing to submit a pull request?

Absolutely :-) #1545

ggrossetie pushed a commit that referenced this issue May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👶 good first issue Good for newcomers 🐋 docker Related to Docker code 🍩 enhancement New feature or request 👋 help wanted Help wanted!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants