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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ RUN apk add --no-cache \

FROM scratch
LABEL "com.centurylinklabs.watchtower"="true"
LABEL "org.opencontainers.image.url"="https://containrrr.dev/watchtower/" \
"org.opencontainers.image.documentation"="https://containrrr.dev/watchtower/" \
"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.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)


COPY --from=alpine \
/etc/ssl/certs/ca-certificates.crt \
Expand Down
7 changes: 7 additions & 0 deletions dockerfiles/Dockerfile.self-contained
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ RUN \
FROM scratch

LABEL "com.centurylinklabs.watchtower"="true"
LABEL "org.opencontainers.image.url"="https://containrrr.dev/watchtower/" \
"org.opencontainers.image.documentation"="https://containrrr.dev/watchtower/" \
"org.opencontainers.image.source"="https://github.com/containrrr/watchtower" \
"org.opencontainers.image.licenses"="Apache-2.0" \
"org.opencontainers.image.title"="watchtower" \
"org.opencontainers.image.description"="A process for automating Docker container base image updates." \
"org.opencontainers.image.base.name"="alpine"

# copy files from other container
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
Expand Down
24 changes: 20 additions & 4 deletions goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ archives:
dockers:
-
use_buildx: true
build_flag_templates: [ "--platform=linux/amd64" ]
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
goos: linux
goarch: amd64
goarm: ''
Expand All @@ -44,7 +48,11 @@ dockers:
- watchtower
-
use_buildx: true
build_flag_templates: [ "--platform=linux/386" ]
build_flag_templates:
- "--platform=linux/386"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
goos: linux
goarch: 386
goarm: ''
Expand All @@ -58,7 +66,11 @@ dockers:
- watchtower
-
use_buildx: true
build_flag_templates: [ "--platform=linux/arm/v6" ]
build_flag_templates:
- "--platform=linux/arm/v6"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
goos: linux
goarch: arm
goarm: 6
Expand All @@ -72,7 +84,11 @@ dockers:
- watchtower
-
use_buildx: true
build_flag_templates: [ "--platform=linux/arm64/v8" ]
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
goos: linux
goarch: arm64
goarm: ''
Expand Down