Skip to content

Commit

Permalink
Dockerfile improvements:
Browse files Browse the repository at this point in the history
Fix docker image version
Exclude outdated pp37 & pp38
Include cp312 & pp310
Upgrade X265, LIBDE265 & LIBAOM to latest versions
Check actual libheif versions
  • Loading branch information
homm committed Aug 16, 2024
1 parent 0d01010 commit 0f70c6a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 34 deletions.
80 changes: 46 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG PLAT=manylinux2014_x86_64

FROM quay.io/pypa/$PLAT AS base
FROM quay.io/pypa/$PLAT:2024.08.12-1 AS base


###############
Expand Down Expand Up @@ -42,7 +42,7 @@ FROM build-tools AS build-deps

# x265
RUN set -ex \
&& X265_VERSION="3.5" \
&& X265_VERSION="3.6" \
&& curl -fLO https://bitbucket.org/multicoreware/x265_git/downloads/x265_${X265_VERSION}.tar.gz \
&& tar xvf x265_${X265_VERSION}.tar.gz \
&& cd x265_${X265_VERSION} \
Expand All @@ -52,7 +52,7 @@ RUN set -ex \

# libde265
RUN set -ex \
&& LIBDE265_VERSION="1.0.12" \
&& LIBDE265_VERSION="1.0.15" \
&& curl -fLO https://github.com/strukturag/libde265/releases/download/v${LIBDE265_VERSION}/libde265-${LIBDE265_VERSION}.tar.gz \
&& tar xvf libde265-${LIBDE265_VERSION}.tar.gz \
&& cd libde265-${LIBDE265_VERSION} \
Expand All @@ -63,7 +63,7 @@ RUN set -ex \

# libaom
RUN set -ex \
&& LIBAOM_VERSION="v3.6.1" \
&& LIBAOM_VERSION="v3.8.3" \
&& mkdir -v aom && mkdir -v aom_build && cd aom \
&& curl -fLO "https://aomedia.googlesource.com/aom/+archive/${LIBAOM_VERSION}.tar.gz" \
&& tar xvf ${LIBAOM_VERSION}.tar.gz \
Expand All @@ -73,22 +73,38 @@ RUN set -ex \
&& make -j $(nproc) && make install && ldconfig \
&& rm -rf /build

# libheif
##################
# libheif 1.18.2 #
##################

FROM build-deps AS libheif
ARG LIBHEIF_VERSION=1.18.2
ARG PLAT

RUN set -ex \
&& LIBHEIF_VERSION="1.16.2" \
&& LIBHEIF_VERSION="$LIBHEIF_VERSION" \
&& curl -fLO https://github.com/strukturag/libheif/releases/download/v${LIBHEIF_VERSION}/libheif-${LIBHEIF_VERSION}.tar.gz \
&& tar xvf libheif-${LIBHEIF_VERSION}.tar.gz && mv libheif-${LIBHEIF_VERSION} libheif \
&& mkdir libheif_build && cd libheif_build \
&& cmake --install-prefix=/usr --preset=release-noplugins -DWITH_EXAMPLES=no ../libheif \
&& make -j $(nproc) && make install && ldconfig \
&& rm -rf /build

COPY ./ /pyheif

RUN set -ex \
&& PNV="/opt/python/cp310-cp310/bin" \
&& $PNV/pip wheel /pyheif \
&& auditwheel repair pyheif*.whl --plat $PLAT -w /wheelhouse \
&& $PNV/pip install --only-binary pillow==10.4.0 -r /pyheif/requirements-test.txt \
&& $PNV/pip install /wheelhouse/*-cp310-*.whl \
&& cd /pyheif && $PNV/pytest

##########################
# Build manylinux wheels #
##########################

FROM build-deps AS repaired
FROM libheif AS all-pythons-repaired
ARG PLAT

COPY ./ /pyheif
Expand All @@ -98,9 +114,9 @@ RUN /opt/python/cp38-cp38/bin/pip wheel /pyheif
RUN /opt/python/cp39-cp39/bin/pip wheel /pyheif
RUN /opt/python/cp310-cp310/bin/pip wheel /pyheif
RUN /opt/python/cp311-cp311/bin/pip wheel /pyheif
RUN /opt/python/pp37-pypy37_pp73/bin/pip wheel /pyheif
RUN /opt/python/pp38-pypy38_pp73/bin/pip wheel /pyheif
RUN /opt/python/cp312-cp312/bin/pip wheel /pyheif
RUN /opt/python/pp39-pypy39_pp73/bin/pip wheel /pyheif
RUN /opt/python/pp310-pypy310_pp73/bin/pip wheel /pyheif
RUN auditwheel repair pyheif*.whl --plat $PLAT -w /wheelhouse


Expand All @@ -109,23 +125,19 @@ RUN auditwheel repair pyheif*.whl --plat $PLAT -w /wheelhouse
###############

FROM base AS tested
ARG PLAT

COPY ./requirements-test.txt /tmp/requirements-test.txt

RUN /opt/python/cp37-cp37m/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt
RUN /opt/python/cp38-cp38/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt
RUN /opt/python/cp39-cp39/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt
RUN /opt/python/cp310-cp310/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt
RUN /opt/python/cp311-cp311/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt
RUN if [ "$PLAT" != "manylinux2014_aarch64" ]; then \
/opt/python/pp37-pypy37_pp73/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt ; fi
RUN if [ "$PLAT" != "manylinux2014_aarch64" ]; then \
/opt/python/pp38-pypy38_pp73/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt ; fi
RUN if [ "$PLAT" != "manylinux2014_aarch64" ]; then \
/opt/python/pp39-pypy39_pp73/bin/pip install --only-binary pillow -r /tmp/requirements-test.txt ; fi

COPY --from=repaired /wheelhouse /wheelhouse
RUN /opt/python/cp37-cp37m/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/cp38-cp38/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/cp39-cp39/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/cp310-cp310/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/cp311-cp311/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/cp312-cp312/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/pp39-pypy39_pp73/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt
RUN /opt/python/pp310-pypy310_pp73/bin/pip install --only-binary pillow==10.4.0 -r /tmp/requirements-test.txt

COPY --from=all-pythons-repaired /wheelhouse /wheelhouse
COPY ./ /pyheif
WORKDIR /pyheif

Expand Down Expand Up @@ -154,21 +166,21 @@ RUN set -ex \
&& PNV="/opt/python/cp311-cp311/bin" \
&& $PNV/pip install /wheelhouse/*-cp311-*.whl \
&& $PNV/pytest
# pypy 3.7
# python 3.12
RUN set -ex \
&& PNV="/opt/python/pp37-pypy37_pp73/bin/" \
&& $PNV/pip install /wheelhouse/*-pp37-*.whl \
&& if [ "$PLAT" != "manylinux2014_aarch64" ]; then $PNV/pytest ; fi
# pypy 3.8
RUN set -ex \
&& PNV="/opt/python/pp38-pypy38_pp73/bin/" \
&& $PNV/pip install /wheelhouse/*-pp38-*.whl \
&& if [ "$PLAT" != "manylinux2014_aarch64" ]; then $PNV/pytest ; fi
&& PNV="/opt/python/cp312-cp312/bin" \
&& $PNV/pip install /wheelhouse/*-cp312-*.whl \
&& $PNV/pytest
# pypy 3.9
RUN set -ex \
&& PNV="/opt/python/pp39-pypy39_pp73/bin/" \
&& PNV="/opt/python/pp39-pypy39_pp73/bin" \
&& $PNV/pip install /wheelhouse/*-pp39-*.whl \
&& if [ "$PLAT" != "manylinux2014_aarch64" ]; then $PNV/pytest ; fi
&& $PNV/pytest
# pypy 3.10
RUN set -ex \
&& PNV="/opt/python/pp310-pypy310_pp73/bin" \
&& $PNV/pip install /wheelhouse/*-pp310-*.whl \
&& $PNV/pytest


#################
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: check_libheif_versions

PLAT ?= manylinux2014_x86_64

check_libheif_versions:
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.16.1 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.16.2 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.17.0 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.17.5 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.17.6 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.18.0 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.18.1 .
docker build --target=libheif --build-arg=PLAT=${PLAT} --build-arg=LIBHEIF_VERSION=1.18.2 .

test:
docker build --target=tested --build-arg=PLAT=${PLAT} .

0 comments on commit 0f70c6a

Please sign in to comment.