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 image labels #1924

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add OCI image labels #1924

wants to merge 2 commits into from

Conversation

Qup42
Copy link

@Qup42 Qup42 commented Feb 6, 2024

This PR adds Labels to the Docker Image. The added Labels conform to the Annotations defined in the OCI Image Format Specification.
The following labels are added for releases (dev and tagged):

  • org.opencontainers.image.url
  • org.opencontainers.image.documentation
  • org.opencontainers.image.source
  • org.opencontainers.image.licenses
  • org.opencontainers.image.title
  • org.opencontainers.image.description
  • org.opencontainers.image.base.name

Tagged releases are additionally labeled with

  • org.opencontainers.image.created
  • org.opencontainers.image.version
  • org.opencontainers.image.revision

Image Labels are considered a best practice for Container Images. They make it easier to handle Images and reconstruct which version one is running. Image Labels also enable tools for automatic dependency updates (like Renovate and Dependabot) to automatically retrieve and display Release Notes for an update.

I tested the changes locally with goreleaser release --skip-publish --skip-validate --rm-dist. The images had the expected labels. There are no existing test suites that apply to this change.

Documentation updates are not required for this change.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations on opening your first pull request! We'll get back to you as soon as possible. In the meantime, please make sure you've updated the documentation to reflect your changes and have added test automation as needed. Thanks! 🙏🏼

"org.opencontainers.image.source"="https://github.com/containrrr/watchtower" \
"org.opencontainers.image.licenses"="Apache-2.0" \
# unsure about capitalization
"org.opencontainers.image.title"="watchtower" \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any feelings about the capitalization of watchtower? As a non-native speaker I am a bit unsure.

"org.opencontainers.image.title"="watchtower" \
"org.opencontainers.image.description"="A process for automating Docker container base image updates." \
# The version might be forgotten. The version could be extraced into a `ARG` before the initial `FROM` or removed.
"org.opencontainers.image.base.name"="alpine:3.19.0"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any feelings? If not I would tend towards removing the concrete version. It adds little in additional information but makes the Dockerfile somewhat more complex.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could be able to do something like

ARG BASE_IMAGE=alpine:3.19.0

FROM --platform=$BUILDPLATFORM $BASE_IMAGE as alpine
[..]
FROM scratch
ARG BASE_IMAGE
LABEL "org.opencontainers.image.base.name"="$BASE_IMAGE"

can't comment on if it would be useful in practice (can't recall ever looking for the labels myself)

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

Successfully merging this pull request may close these issues.

2 participants