diff --git a/python/3.10/focal/Containerfile b/python/3.10/focal/Containerfile index 31698d82..0f92f596 100644 --- a/python/3.10/focal/Containerfile +++ b/python/3.10/focal/Containerfile @@ -4,12 +4,12 @@ ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:focal FROM $BASE_IMAGE # ensure local python is preferred over distribution python -ENV PATH /usr/local/bin:$PATH +ENV PATH=/usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 # runtime dependencies RUN set -eux; \ @@ -21,9 +21,9 @@ RUN set -eux; \ ; \ rm -rf /var/lib/apt/lists/* -ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D -ENV PYTHON_VERSION 3.10.15 -ENV PYTHON_SHA256 aab0950817735172601879872d937c1e4928a57c409ae02369ec3d91dccebe79 +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # hadolint ignore=DL3003,DL3013,SC2015 diff --git a/python/3.10/focal/docker-bake.hcl b/python/3.10/focal/docker-bake.hcl index da5ebc85..49f853c2 100644 --- a/python/3.10/focal/docker-bake.hcl +++ b/python/3.10/focal/docker-bake.hcl @@ -3,7 +3,7 @@ variable "TAG_PREFIX" { } variable "VERSION" { - default = "3.10.15" + default = "3.10.16" } # There's no darwin-based Docker, so if we're running on macOS, change the platform to linux diff --git a/python/3.10/jammy/Containerfile b/python/3.10/jammy/Containerfile index 6131665b..47f4011c 100644 --- a/python/3.10/jammy/Containerfile +++ b/python/3.10/jammy/Containerfile @@ -4,12 +4,12 @@ ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:jammy FROM $BASE_IMAGE # ensure local python is preferred over distribution python -ENV PATH /usr/local/bin:$PATH +ENV PATH=/usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 # runtime dependencies RUN set -eux; \ @@ -21,9 +21,9 @@ RUN set -eux; \ ; \ rm -rf /var/lib/apt/lists/* -ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D -ENV PYTHON_VERSION 3.10.15 -ENV PYTHON_SHA256 aab0950817735172601879872d937c1e4928a57c409ae02369ec3d91dccebe79 +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # hadolint ignore=DL3003,DL3013,SC2015 diff --git a/python/3.10/jammy/docker-bake.hcl b/python/3.10/jammy/docker-bake.hcl index da5ebc85..49f853c2 100644 --- a/python/3.10/jammy/docker-bake.hcl +++ b/python/3.10/jammy/docker-bake.hcl @@ -3,7 +3,7 @@ variable "TAG_PREFIX" { } variable "VERSION" { - default = "3.10.15" + default = "3.10.16" } # There's no darwin-based Docker, so if we're running on macOS, change the platform to linux diff --git a/python/3.10/noble/Containerfile b/python/3.10/noble/Containerfile new file mode 100644 index 00000000..9d8f0b7a --- /dev/null +++ b/python/3.10/noble/Containerfile @@ -0,0 +1,111 @@ +# syntax=docker/dockerfile:1 +ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:noble +# hadolint ignore=DL3006 +FROM $BASE_IMAGE + +# ensure local python is preferred over distribution python +ENV PATH=/usr/local/bin:$PATH + +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +ENV LANG=C.UTF-8 + +# runtime dependencies +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libbluetooth-dev \ + tk-dev \ + uuid-dev \ + ; \ + rm -rf /var/lib/apt/lists/* + +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# hadolint ignore=DL3003,DL3013,SC2015 +RUN set -eux; \ + \ + curl -fsSL -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ + echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ + curl -fsSL -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ + gpg --batch --verify python.tar.xz.asc python.tar.xz; \ + gpgconf --kill all; \ + rm -rf "$GNUPGHOME" python.tar.xz.asc; \ + mkdir -p /usr/src/python; \ + tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ + rm python.tar.xz; \ + \ + cd /usr/src/python; \ + gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ + ./configure \ + --build="$gnuArch" \ + --enable-loadable-sqlite-extensions \ + --enable-optimizations \ + --enable-option-checking=fatal \ + --enable-shared \ + --with-lto \ + --with-ensurepip \ + ; \ + nproc="$(nproc)"; \ + EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ + LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:-}" \ + ; \ +# https://github.com/docker-library/python/issues/784 +# prevent accidental usage of a system installed libpython of the same version + rm python; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ + python \ + ; \ + make install; \ + \ +# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 + bin="$(readlink -ve /usr/local/bin/python3)"; \ + dir="$(dirname "$bin")"; \ + mkdir -p "/usr/share/gdb/auto-load/$dir"; \ + cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ + \ + cd /; \ + rm -rf /usr/src/python; \ + \ + find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ + -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + \) -exec rm -rf '{}' + \ + ; \ + \ + ldconfig; \ + \ + export PYTHONDONTWRITEBYTECODE=1; \ + python3 --version; \ + \ + pip3 install \ + --disable-pip-version-check \ + --no-cache-dir \ + --no-compile \ + 'setuptools==65.5.1' \ + wheel \ + ; \ + pip3 --version + +# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) +RUN set -eux; \ + for src in idle3 pip3 pydoc3 python3 python3-config; do \ + dst="$(echo "$src" | tr -d 3)"; \ + [ -s "/usr/local/bin/$src" ]; \ + [ ! -e "/usr/local/bin/$dst" ]; \ + ln -svT "$src" "/usr/local/bin/$dst"; \ + done + +CMD ["python3"] \ No newline at end of file diff --git a/python/3.10/noble/docker-bake.hcl b/python/3.10/noble/docker-bake.hcl new file mode 100644 index 00000000..fbb68d20 --- /dev/null +++ b/python/3.10/noble/docker-bake.hcl @@ -0,0 +1,38 @@ +variable "TAG_PREFIX" { + default = "docker.io/polymathrobotics/python" +} + +variable "VERSION" { + default = "3.10.16" +} + +# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux +variable "LOCAL_PLATFORM" { + default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux") +} + +target "_common" { + dockerfile = "Containerfile" + tags = [ + "${TAG_PREFIX}:${VERSION}-noble", + "${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-noble", + ] + labels = { + "org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci" + "org.opencontainers.image.licenses" = "Apache-2.0" + "org.opencontainers.image.description" = "Python is an interpreted, interactive, object-oriented, open-source programming language." + "org.opencontainers.image.title" = "${TAG_PREFIX}" + "org.opencontainers.image.created" = "${timestamp()}" + "dev.polymathrobotics.image.readme-filepath" = "python/README.md" + } +} + +target "local" { + inherits = ["_common"] + platforms = ["${LOCAL_PLATFORM}"] +} + +target "default" { + inherits = ["_common"] + platforms = ["linux/amd64", "linux/arm64/v8"] +} \ No newline at end of file diff --git a/python/3.10/noble/test/controls/python.rb b/python/3.10/noble/test/controls/python.rb new file mode 100644 index 00000000..2077bd77 --- /dev/null +++ b/python/3.10/noble/test/controls/python.rb @@ -0,0 +1,3 @@ +describe command('python3') do + it { should exist } +end diff --git a/python/3.10/slim-focal/Containerfile b/python/3.10/slim-focal/Containerfile index e1529fb3..42bdbd11 100644 --- a/python/3.10/slim-focal/Containerfile +++ b/python/3.10/slim-focal/Containerfile @@ -4,26 +4,26 @@ ARG BASE_IMAGE=docker.io/ubuntu:focal-20241011 FROM $BASE_IMAGE # ensure local python is preferred over distribution python -ENV PATH /usr/local/bin:$PATH +ENV PATH=/usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 # runtime dependencies RUN set -eux; \ apt-get update; \ - apt-get install -y --no-install-recommends \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ netbase \ tzdata \ ; \ rm -rf /var/lib/apt/lists/* -ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D -ENV PYTHON_VERSION 3.10.15 -ENV PYTHON_SHA256 aab0950817735172601879872d937c1e4928a57c409ae02369ec3d91dccebe79 +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # hadolint ignore=DL3003,DL3013,DL3047,SC2086 diff --git a/python/3.10/slim-focal/docker-bake.hcl b/python/3.10/slim-focal/docker-bake.hcl index 1cb71e53..c319638d 100644 --- a/python/3.10/slim-focal/docker-bake.hcl +++ b/python/3.10/slim-focal/docker-bake.hcl @@ -1,9 +1,9 @@ variable "TAG_PREFIX" { - default = "docker.io/polymathrobotics/python" + default = "docker.io/polymathrobotics/python" } variable "VERSION" { - default = "3.10.15" + default = "3.10.16" } # There's no darwin-based Docker, so if we're running on macOS, change the platform to linux diff --git a/python/3.10/slim-jammy/Containerfile b/python/3.10/slim-jammy/Containerfile index a8dad8c6..781cc8ce 100644 --- a/python/3.10/slim-jammy/Containerfile +++ b/python/3.10/slim-jammy/Containerfile @@ -4,26 +4,26 @@ ARG BASE_IMAGE=docker.io/ubuntu:jammy-20240911.1 FROM $BASE_IMAGE # ensure local python is preferred over distribution python -ENV PATH /usr/local/bin:$PATH +ENV PATH=/usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 # runtime dependencies RUN set -eux; \ apt-get update; \ - apt-get install -y --no-install-recommends \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ netbase \ tzdata \ ; \ rm -rf /var/lib/apt/lists/* -ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D -ENV PYTHON_VERSION 3.10.15 -ENV PYTHON_SHA256 aab0950817735172601879872d937c1e4928a57c409ae02369ec3d91dccebe79 +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # hadolint ignore=DL3003,DL3013,DL3047,SC2086 diff --git a/python/3.10/slim-jammy/docker-bake.hcl b/python/3.10/slim-jammy/docker-bake.hcl index 1cb71e53..990ef417 100644 --- a/python/3.10/slim-jammy/docker-bake.hcl +++ b/python/3.10/slim-jammy/docker-bake.hcl @@ -3,7 +3,7 @@ variable "TAG_PREFIX" { } variable "VERSION" { - default = "3.10.15" + default = "3.10.16" } # There's no darwin-based Docker, so if we're running on macOS, change the platform to linux diff --git a/python/3.10/slim-noble/Containerfile b/python/3.10/slim-noble/Containerfile new file mode 100644 index 00000000..d9077495 --- /dev/null +++ b/python/3.10/slim-noble/Containerfile @@ -0,0 +1,144 @@ +# syntax=docker/dockerfile:1 +ARG BASE_IMAGE=docker.io/ubuntu:noble-20241118.1 +# hadolint ignore=DL3006 +FROM $BASE_IMAGE + +# ensure local python is preferred over distribution python +ENV PATH=/usr/local/bin:$PATH + +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +ENV LANG=C.UTF-8 + +# runtime dependencies +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates \ + netbase \ + tzdata \ + ; \ + rm -rf /var/lib/apt/lists/* + +ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D +ENV PYTHON_VERSION=3.10.16 +ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# hadolint ignore=DL3003,DL3013,DL3047,SC2086 +RUN set -eux; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + dpkg-dev \ + gcc \ + gnupg \ + libbluetooth-dev \ + libbz2-dev \ + libc6-dev \ + libdb-dev \ + libffi-dev \ + libgdbm-dev \ + liblzma-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + make \ + tk-dev \ + uuid-dev \ + wget \ + xz-utils \ + zlib1g-dev \ + ; \ + \ + wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ + echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ + wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ + gpg --batch --verify python.tar.xz.asc python.tar.xz; \ + gpgconf --kill all; \ + rm -rf "$GNUPGHOME" python.tar.xz.asc; \ + mkdir -p /usr/src/python; \ + tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ + rm python.tar.xz; \ + \ + cd /usr/src/python; \ + gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ + ./configure \ + --build="$gnuArch" \ + --enable-loadable-sqlite-extensions \ + --enable-optimizations \ + --enable-option-checking=fatal \ + --enable-shared \ + --with-lto \ + --with-ensurepip \ + ; \ + nproc="$(nproc)"; \ + EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ + LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ + LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:-}" \ + ; \ +# https://github.com/docker-library/python/issues/784 +# prevent accidental usage of a system installed libpython of the same version + rm python; \ + make -j "$nproc" \ + "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ + "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ + python \ + ; \ + make install; \ + \ + cd /; \ + rm -rf /usr/src/python; \ + \ + find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ + -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ + \) -exec rm -rf '{}' + \ + ; \ + \ + ldconfig; \ + \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ + | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ + | sort -u \ + | xargs -r dpkg-query --search \ + | cut -d: -f1 \ + | sort -u \ + | xargs -r apt-mark manual \ + ; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + \ + export PYTHONDONTWRITEBYTECODE=1; \ + python3 --version; \ + \ + pip3 install \ + --disable-pip-version-check \ + --no-cache-dir \ + --no-compile \ + 'setuptools==65.5.1' \ + wheel \ + ; \ + pip3 --version + +# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) +RUN set -eux; \ + for src in idle3 pip3 pydoc3 python3 python3-config; do \ + dst="$(echo "$src" | tr -d 3)"; \ + [ -s "/usr/local/bin/$src" ]; \ + [ ! -e "/usr/local/bin/$dst" ]; \ + ln -svT "$src" "/usr/local/bin/$dst"; \ + done + +CMD ["python3"] \ No newline at end of file diff --git a/python/3.10/slim-noble/docker-bake.hcl b/python/3.10/slim-noble/docker-bake.hcl new file mode 100644 index 00000000..7e2997c3 --- /dev/null +++ b/python/3.10/slim-noble/docker-bake.hcl @@ -0,0 +1,38 @@ +variable "TAG_PREFIX" { + default = "docker.io/polymathrobotics/python" +} + +variable "VERSION" { + default = "3.10.16" +} + +# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux +variable "LOCAL_PLATFORM" { + default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux") +} + +target "_common" { + dockerfile = "Containerfile" + tags = [ + "${TAG_PREFIX}:${VERSION}-slim-noble", + "${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-slim-noble", + ] + labels = { + "org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci" + "org.opencontainers.image.licenses" = "Apache-2.0" + "org.opencontainers.image.description" = "Python is an interpreted, interactive, object-oriented, open-source programming language." + "org.opencontainers.image.title" = "${TAG_PREFIX}" + "org.opencontainers.image.created" = "${timestamp()}" + "dev.polymathrobotics.image.readme-filepath" = "python/README.md" + } +} + +target "local" { + inherits = ["_common"] + platforms = ["${LOCAL_PLATFORM}"] +} + +target "default" { + inherits = ["_common"] + platforms = ["linux/amd64", "linux/arm64/v8"] +}