Skip to content

Commit cd2e370

Browse files
committed
Use python/requirements.txt to install dependencies.
Simplify pip cache management and make it working.
1 parent 3b3115a commit cd2e370

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docker/Dockerfile.python_wheels

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# syntax=docker/dockerfile:1.7-labs
22

33
ARG BASE_IMAGE="quay.io/pypa/manylinux_2_28:latest"
4+
ARG CACHE_IMAGE="scratch"
5+
6+
FROM ${CACHE_IMAGE} AS pipcache
7+
48
FROM --platform=$TARGETPLATFORM $BASE_IMAGE AS build
59
LABEL maintainer="Maksym Sobolyev <sobomax@sippysoft.com>"
610

@@ -11,15 +15,20 @@ WORKDIR /src
1115
ARG PY_VER
1216
ARG 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+
1423
RUN --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

1828
COPY --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
2332
RUN auditwheel repair dist/*.whl --wheel-dir dist_out
2433

2534
FROM build AS test
@@ -29,4 +38,5 @@ RUN date > dist_out/test_done.ts
2938

3039
FROM scratch AS export
3140
COPY --from=build /src/dist_out /dist
41+
COPY --from=build /root/.cache/pip /root/.cache/pip
3242
COPY --from=test /src/dist_out/test_done.ts /dist

scripts/build/install_depends_wheels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ PYTHON_CMD="${PYTHON_CMD:-"python${PY_VER}"}"
66

77
${PYTHON_CMD} -m ensurepip --upgrade
88
${PYTHON_CMD} -m pip install --upgrade pip
9-
${PYTHON_CMD} -m pip install --upgrade build setuptools wheel auditwheel numpy
9+
${PYTHON_CMD} -m pip install --upgrade build setuptools wheel auditwheel

0 commit comments

Comments
 (0)