Skip to content
Merged
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
24 changes: 13 additions & 11 deletions python/3.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ FROM $BUILD_FROM
ARG \
PYTHON_VERSION \
PIP_VERSION \
GPG_KEY \
CERT_IDENTITY \
CERT_OIDC_ISSUER \
QEMU_CPU

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH
ENV PATH=/usr/local/bin:$PATH
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think the space variant also did not expand $PATH... I wonder how certain things even worked with that in mind 🤔

Anyways, this is the right thing to do 👍


# Set shell
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
Expand All @@ -17,19 +18,20 @@ COPY *.patch /usr/src/
RUN set -ex \
&& export PYTHON_VERSION=${PYTHON_VERSION} \
&& apk add --no-cache --virtual .fetch-deps \
gnupg \
openssl \
tar \
xz \
&& apk add --no-cache --virtual .cosign cosign \
--repository="https://dl-cdn.alpinelinux.org/alpine/v3.21/community" \
\
&& curl -L -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& curl -L -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf" \
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "${GPG_KEY}" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& curl -L -o python.tar.xz.sigstore "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.sigstore" \
&& cosign verify-blob \
--new-bundle-format \
--certificate-identity "${CERT_IDENTITY}" \
--certificate-oidc-issuer "${CERT_OIDC_ISSUER}" \
--bundle python.tar.xz.sigstore \
python.tar.xz \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
Expand Down Expand Up @@ -63,7 +65,7 @@ RUN set -ex \
zlib-dev \
bluez-dev \
# add build deps before removing fetch deps in case there's overlap
&& apk del .fetch-deps \
&& apk del .fetch-deps .cosign \
\
&& for i in /usr/src/*.patch; do \
patch -d /usr/src/python -p 1 < "${i}"; done \
Expand Down
3 changes: 2 additions & 1 deletion python/3.11/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cosign:
args:
PYTHON_VERSION: 3.11.13
PIP_VERSION: 25.1.1
GPG_KEY: A035C8C19219BA821ECEA86B64E628F8D684696D
CERT_IDENTITY: [email protected]
CERT_OIDC_ISSUER: https://accounts.google.com
labels:
io.hass.base.name: python
org.opencontainers.image.source: https://github.com/home-assistant/docker-base
24 changes: 13 additions & 11 deletions python/3.12/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ FROM $BUILD_FROM
ARG \
PYTHON_VERSION \
PIP_VERSION \
GPG_KEY \
CERT_IDENTITY \
CERT_OIDC_ISSUER \
QEMU_CPU

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH
ENV PATH=/usr/local/bin:$PATH

# Set shell
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
Expand All @@ -17,19 +18,20 @@ COPY *.patch /usr/src/
RUN set -ex \
&& export PYTHON_VERSION=${PYTHON_VERSION} \
&& apk add --no-cache --virtual .fetch-deps \
gnupg \
openssl \
tar \
xz \
&& apk add --no-cache --virtual .cosign cosign \
--repository="https://dl-cdn.alpinelinux.org/alpine/v3.21/community" \
Comment on lines +24 to +25
Copy link
Member Author

@cdce8p cdce8p Jun 5, 2025

Choose a reason for hiding this comment

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

The Python sigstore bundle use the new bundle format, the verification of which requires cosign>=4.2.0. Unfortunately alpine 3.21 is the earliest release with in this case version 4.2.1. The additional repository is necessary until 3.19 and 3.20 are dropped.

There is a draft PR to add sigstore validation to the "official" Python docker images which uses a similar approach. docker-library/python#983

https://pkgs.alpinelinux.org/packages?name=cosign&branch=v3.21&repo=&arch=x86_64&origin=&flagged=&maintainer=

\
&& curl -L -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& curl -L -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf" \
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "${GPG_KEY}" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& curl -L -o python.tar.xz.sigstore "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.sigstore" \
&& cosign verify-blob \
--new-bundle-format \
--certificate-identity "${CERT_IDENTITY}" \
--certificate-oidc-issuer "${CERT_OIDC_ISSUER}" \
--bundle python.tar.xz.sigstore \
python.tar.xz \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
Expand Down Expand Up @@ -63,7 +65,7 @@ RUN set -ex \
zlib-dev \
bluez-dev \
# add build deps before removing fetch deps in case there's overlap
&& apk del .fetch-deps \
&& apk del .fetch-deps .cosign \
\
&& for i in /usr/src/*.patch; do \
patch -d /usr/src/python -p 1 < "${i}"; done \
Expand Down
3 changes: 2 additions & 1 deletion python/3.12/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cosign:
args:
PYTHON_VERSION: 3.12.11
PIP_VERSION: 25.1.1
GPG_KEY: 7169605F62C751356D054A26A821E680E5FA6305
CERT_IDENTITY: [email protected]
CERT_OIDC_ISSUER: https://accounts.google.com
labels:
io.hass.base.name: python
org.opencontainers.image.source: https://github.com/home-assistant/docker-base
24 changes: 13 additions & 11 deletions python/3.13/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ FROM $BUILD_FROM
ARG \
PYTHON_VERSION \
PIP_VERSION \
GPG_KEY \
CERT_IDENTITY \
CERT_OIDC_ISSUER \
QEMU_CPU

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH
ENV PATH=/usr/local/bin:$PATH

# Set shell
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
Expand All @@ -17,19 +18,20 @@ COPY *.patch /usr/src/
RUN set -ex \
&& export PYTHON_VERSION=${PYTHON_VERSION} \
&& apk add --no-cache --virtual .fetch-deps \
gnupg \
openssl \
tar \
xz \
&& apk add --no-cache --virtual .cosign cosign \
--repository="https://dl-cdn.alpinelinux.org/alpine/v3.21/community" \
\
&& curl -L -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& curl -L -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf" \
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "${GPG_KEY}" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& curl -L -o python.tar.xz.sigstore "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.sigstore" \
&& cosign verify-blob \
--new-bundle-format \
--certificate-identity "${CERT_IDENTITY}" \
--certificate-oidc-issuer "${CERT_OIDC_ISSUER}" \
--bundle python.tar.xz.sigstore \
python.tar.xz \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
Expand Down Expand Up @@ -63,7 +65,7 @@ RUN set -ex \
zlib-dev \
bluez-dev \
# add build deps before removing fetch deps in case there's overlap
&& apk del .fetch-deps \
&& apk del .fetch-deps .cosign \
\
&& for i in /usr/src/*.patch; do \
patch -d /usr/src/python -p 1 < "${i}"; done \
Expand Down
3 changes: 2 additions & 1 deletion python/3.13/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cosign:
args:
PYTHON_VERSION: 3.13.4
PIP_VERSION: 25.1.1
GPG_KEY: 7169605F62C751356D054A26A821E680E5FA6305
CERT_IDENTITY: [email protected]
CERT_OIDC_ISSUER: https://accounts.google.com
labels:
io.hass.base.name: python
org.opencontainers.image.source: https://github.com/home-assistant/docker-base