Skip to content

Commit f8498e5

Browse files
committed
Set OCI annotations in the manifest so they show up on the webpage for the images
As well, add in some more common container labels and correct a couple minor mistakes in the metadata.
1 parent 2f56ac4 commit f8498e5

File tree

5 files changed

+69
-2
lines changed

5 files changed

+69
-2
lines changed

.github/workflows/build-and-push.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- name: Set Calver Date
2222
run: |
2323
echo "builddate=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
24+
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
2425
id: version
2526
- name: Checkout
2627
uses: actions/checkout@v5
@@ -34,6 +35,61 @@ jobs:
3435
registry: ghcr.io
3536
username: ${{ github.actor }}
3637
password: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Extract labels from Dockerfile
39+
id: labels
40+
run: |
41+
set -euo pipefail
42+
43+
# Extract labels from the Dockerfile.
44+
DOCKERFILE=./${{ inputs.container }}/Dockerfile
45+
46+
# Function to extract a label value.
47+
extract_label() {
48+
local label_key="$1"
49+
grep "org.opencontainers.image.${label_key}=" "$DOCKERFILE" | \
50+
sed -n 's/.*org\.opencontainers\.image\.'"${label_key}"'="\([^"]*\)".*/\1/p' | \
51+
head -n1 || echo ''
52+
}
53+
54+
# Function to add annotation if value is non-empty.
55+
add_annotation() {
56+
local key="$1"
57+
local value="$2"
58+
if [ -n "$value" ]; then
59+
[ -n "$annotations" ] && annotations="$annotations,"
60+
annotations="${annotations}annotation-index.org.opencontainers.image.${key}=${value}"
61+
fi
62+
}
63+
64+
# Extract static labels from Dockerfile.
65+
source=$(extract_label "source")
66+
description=$(extract_label "description")
67+
title=$(extract_label "title")
68+
authors=$(extract_label "authors")
69+
base_name=$(extract_label "base.name")
70+
licenses=$(extract_label "licenses")
71+
url=$(extract_label "url")
72+
documentation=$(extract_label "documentation")
73+
74+
# Get dynamic values from earlier steps.
75+
created="${{ steps.version.outputs.created }}"
76+
revision="${{ github.sha }}"
77+
78+
# Build annotations string.
79+
annotations=""
80+
add_annotation "source" "$source"
81+
add_annotation "description" "$description"
82+
add_annotation "title" "$title"
83+
add_annotation "authors" "$authors"
84+
add_annotation "base.name" "$base_name"
85+
add_annotation "licenses" "$licenses"
86+
add_annotation "url" "$url"
87+
add_annotation "documentation" "$documentation"
88+
add_annotation "created" "$created"
89+
add_annotation "revision" "$revision"
90+
91+
# Output the complete annotations string.
92+
echo "annotations=$annotations" >> $GITHUB_OUTPUT
3793
- name: Build and push
3894
uses: docker/build-push-action@v6
3995
with:
@@ -43,3 +99,4 @@ jobs:
4399
tags: |
44100
ghcr.io/python/${{ inputs.container }}:${{ steps.version.outputs.builddate }}.${{ github.run_id }}
45101
ghcr.io/python/${{ inputs.container }}:latest
102+
outputs: type=image,name=ghcr.io/python/${{ inputs.container }},${{ steps.labels.outputs.annotations }}

autoconf/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ ARG AUTOMAKE_VERSION="1.16.5"
88
ARG CONFIG_GIT_REV="00b15927496058d23e6258a28d8996f87cf1f191"
99

1010
LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcontainers"
11-
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:22.04"
11+
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:24.04"
1212
LABEL org.opencontainers.image.authors="Donghee Na"
1313
LABEL org.opencontainers.image.title="GNU Autoconf ${AUTOCONF_VERSION} container for CPython"
1414
LABEL org.opencontainers.image.description="Container image with GNU Autoconf ${AUTOCONF_VERSION}, GNU Automake ${AUTOMAKE_VERSION}, and autoconf-archive ${AUTOCONF_ARCHIVE_VERSION} for generating CPython's configure script."
15+
LABEL org.opencontainers.image.licenses="MIT"
16+
LABEL org.opencontainers.image.url="https://github.com/python/cpython-devcontainers"
17+
LABEL org.opencontainers.image.documentation="https://github.com/python/cpython-devcontainers/blob/main/autoconf/README.md"
1518

1619
RUN apt-get update && \
1720
apt-get install -yq \

autoconf/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Container image for recreating `configure` from `configure.ac` for CPython (via the `make regen-configure` command).

devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcont
55
LABEL org.opencontainers.image.title="CPython development container"
66
LABEL org.opencontainers.image.description="CPython development container with the tooling to work on Linux builds."
77
LABEL org.opencontainers.image.authors="Brett Cannon"
8+
LABEL org.opencontainers.image.licenses="MIT"
9+
LABEL org.opencontainers.image.url="https://github.com/python/cpython-devcontainers"
10+
LABEL org.opencontainers.image.documentation="https://github.com/python/cpython-devcontainers/blob/main/devcontainer/README.md"
811

912
ENV CC=clang
1013

wasicontainer/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
FROM ghcr.io/python/devcontainer:latest
22

3-
LABEL org.opencontainers.image.base.name="ghcr.io/python/wasicontainer:latest"
3+
LABEL org.opencontainers.image.base.name="ghcr.io/python/devcontainer:latest"
44
LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcontainers"
55
LABEL org.opencontainers.image.title="CPython WASI development container"
66
LABEL org.opencontainers.image.description="CPython development container with the tooling to work on WASI builds."
77
LABEL org.opencontainers.image.authors="Brett Cannon"
8+
LABEL org.opencontainers.image.licenses="MIT"
9+
LABEL org.opencontainers.image.url="https://github.com/python/cpython-devcontainers"
10+
LABEL org.opencontainers.image.documentation="https://github.com/python/cpython-devcontainers/blob/main/wasicontainer/README.md"
811

912
ARG TARGETARCH
1013

0 commit comments

Comments
 (0)