11# syntax=docker/dockerfile:1.7-labs
22
33ARG BASE_IMAGE="quay.io/pypa/manylinux_2_28:latest"
4+ ARG CACHE_IMAGE="scratch"
5+
6+ FROM ${CACHE_IMAGE} AS pipcache
7+
48FROM --platform=$TARGETPLATFORM $BASE_IMAGE AS build
59LABEL maintainer="Maksym Sobolyev <sobomax@sippysoft.com>"
610
@@ -11,15 +15,20 @@ WORKDIR /src
1115ARG PY_VER
1216ARG PYTHON_CMD
1317
18+ RUN mkdir -p /root/.cache/pip
19+ RUN --mount=type=bind,from=pipcache,source=/,target=/tmp/pip_cache_root \
20+ test ! -d /tmp/pip_cache_root/root/.cache/pip || \
21+ cp -a /tmp/pip_cache_root/root/.cache/pip /root/.cache/pip
22+
1423RUN --mount=type=bind,source=scripts/build,target=scripts/build \
15- --mount=type=cache,id=python-pip,target=/root/.cache/pip \
1624 sh -x scripts/build/install_depends_wheels.sh
25+ RUN --mount=type=bind,source=python/requirements.txt,target=python/requirements.txt \
26+ ${PYTHON_CMD} -m pip install -r python/requirements.txt
1727
1828COPY --exclude=.git --exclude=.github --exclude=docker --exclude=dist \
1929 --exclude=scripts . .
2030
21- RUN --mount=type=cache,id=python-pip,target=/root/.cache/pip \
22- ${PYTHON_CMD} -m build --wheel
31+ RUN ${PYTHON_CMD} -m build --wheel
2332RUN auditwheel repair dist/*.whl --wheel-dir dist_out
2433
2534FROM build AS test
@@ -29,4 +38,5 @@ RUN date > dist_out/test_done.ts
2938
3039FROM scratch AS export
3140COPY --from=build /src/dist_out /dist
41+ COPY --from=build /root/.cache/pip /root/.cache/pip
3242COPY --from=test /src/dist_out/test_done.ts /dist
0 commit comments