Skip to content

Commit

Permalink
Add python3.10 build
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Sapezhko committed Mar 18, 2022
1 parent de70f71 commit 95b1021
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
71 changes: 71 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
ARG DEBIAN_RELEASE

FROM debian:${DEBIAN_RELEASE} as build

ARG DEBIAN_RELEASE
ARG UBUNTU_RELEASE
ARG PYTHON_VERSION
ARG REPO_TAG
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NOWARNINGS=yes

WORKDIR /root
RUN apt-get update -qq \
&& apt-get install -qq -y --no-install-recommends > /dev/null \
libmpdec-dev \
libncursesw5-dev \
blt-dev \
build-essential \
debhelper \
libbluetooth-dev \
libbz2-dev \
libdb-dev \
libexpat1-dev \
libffi-dev \
libgdbm-dev \
libgpm2 \
liblzma-dev \
libncurses-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
locales \
lsb-release \
mime-support \
net-tools \
netbase \
python3-sphinx \
quilt \
sharutils \
texinfo \
time \
tk-dev \
unzip \
xauth \
xvfb \
zlib1g-dev \
&& apt-get -qq clean \
&& rm -rf "/var/lib/apt/lists"/*

ADD https://github.com/deadsnakes/python${PYTHON_VERSION}/archive/refs/tags/${REPO_TAG}.zip python.zip
RUN unzip -q python.zip \
&& cd python*-debian* \
&& sed -ie "s/${UBUNTU_RELEASE}/${DEBIAN_RELEASE}/g" debian/changelog \
&& sed -ie 's/^Maintainer:/Uploaders: Pavel Sapezhka <[email protected]>\nMaintainer:/' debian/control \
&& dpkg-buildpackage -uc -us -b

FROM debian:${DEBIAN_RELEASE} AS test
ARG PYTHON_VERSION
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NOWARNINGS=yes
COPY --from=build /root/*.deb /root/
RUN apt-get update -qq \
&& apt-get install -qq -y --no-install-recommends ./root/*.deb > /dev/null \
&& python${PYTHON_VERSION} -c 'print("OK")' \
&& touch /root/hack

FROM scratch AS export
COPY --from=build /root/*.deb /
# BuildKit ignores stages treated as unneeded for the result
# So we create an artificial need of the test stage by copying file from.
COPY --from=test /root/hack /
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.PHONY: all build clean python3.10-bullseye python3.10-buster python3.10-stretch clean-python3.10-bullseye clean-python3.10-buster clean-python3.10-stretch

all: build

build: python3.10-bullseye python3.10-buster python3.10-stretch

python3.10-bullseye: clean-python3.10-bullseye
@echo "Build Python 3.10 for Debian 11 (bullseye)"
@mkdir -p build/bullseye/python3.10
@DOCKER_BUILDKIT=1 docker build \
--build-arg DEBIAN_RELEASE=bullseye \
--build-arg UBUNTU_RELEASE=focal \
--build-arg PYTHON_VERSION=3.10 \
--build-arg REPO_TAG=debian/3.10.3-1+focal1 \
--output build/bullseye/python3.10 \
--force-rm \
--no-cache \
.
@rm build/bullseye/python3.10/hack

python3.10-buster: clean-python3.10-buster
@echo "Build Python 3.10 for Debian 10 (buster)"
@mkdir -p build/buster/python3.10
@DOCKER_BUILDKIT=1 docker build \
--build-arg DEBIAN_RELEASE=buster \
--build-arg UBUNTU_RELEASE=focal \
--build-arg PYTHON_VERSION=3.10 \
--build-arg REPO_TAG=debian/3.10.3-1+focal1 \
--output build/buster/python3.10 \
--force-rm \
--no-cache \
.
@rm build/buster/python3.10/hack

python3.10-stretch: clean-python3.10-stretch
@echo "Build Python 3.10 for Debian 9 (stretch)"
@mkdir -p build/stretch/python3.10
@DOCKER_BUILDKIT=1 docker build \
--build-arg DEBIAN_RELEASE=stretch \
--build-arg UBUNTU_RELEASE=bionic \
--build-arg PYTHON_VERSION=3.10 \
--build-arg REPO_TAG=debian/3.10.3-1+bionic1 \
--output build/stretch/python3.10 \
--force-rm \
--no-cache \
.
@rm build/stretch/python3.10/hack

clean: clean-python3.10-bullseye clean-python3.10-buster clean-python3.10-stretch

clean-python3.10-bullseye:
@echo "Clean artifacts of build of Python 3.10 for Debian 11 (bullseye)"
@rm -rf build/bullseye/python3.10/*

clean-python3.10-buster:
@echo "Clean artifacts of build of Python 3.10 for Debian 10 (buster)"
@rm -rf build/buster/python3.10/*

clean-python3.10-stretch:
@echo "Clean artifacts of build of Python 3.10 for Debian 9 (stretch)"
@rm -rf build/stretch/python3.10/*

0 comments on commit 95b1021

Please sign in to comment.