未验证 提交 65d43aae 编写于 作者: R Roman Donchenko 提交者: GitHub

Dockerfile: retain the pip download cache between builds (#6035)

This speeds up the build when the entire step can't be cached (e.g. the
requirements file changed), but the package list remains mostly the
same.

The savings are... rather underwhelming, actually. I have observed about
a minute in savings, although it obviously depends on the network
connection speed. I think this is because pip is inefficient at loading
from its own cache (I have observed it loading the entire cached file
into memory, for example).

Still, savings are savings, and we're getting them basically for free,
so why not.

Note that I only persist the HTTP cache, and not the wheel cache. That's
because any wheels that pip builds could depend on the system packages,
and I don't want old wheels to be reused if the system packages change.

Also, disable the pip autoupdate checks, which isn't much of an
optimization, but it gets rid of some pointless warnings.
上级 ad534b2a
......@@ -45,14 +45,17 @@ RUN curl -sL https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 --outp
# Build wheels for all dependencies
ARG PIP_VERSION
RUN python3 -m pip install -U pip==${PIP_VERSION}
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
RUN --mount=type=cache,target=/root/.cache/pip/http \
python3 -m pip install -U pip==${PIP_VERSION}
COPY cvat/requirements/ /tmp/requirements/
COPY utils/dataset_manifest/ /tmp/dataset_manifest/
# The server implementation depends on the dataset_manifest utility
# so we need to build its dependencies too
# https://github.com/opencv/cvat/issues/5096
RUN DATUMARO_HEADLESS=1 python3 -m pip wheel --no-cache-dir \
RUN --mount=type=cache,target=/root/.cache/pip/http \
DATUMARO_HEADLESS=1 python3 -m pip wheel \
-r /tmp/requirements/${DJANGO_CONFIGURATION}.txt \
-r /tmp/dataset_manifest/requirements.txt \
-w /tmp/wheelhouse
......@@ -150,6 +153,8 @@ COPY --from=build-image /tmp/openh264/openh264*.tar.gz /tmp/ffmpeg/ffmpeg*.tar.g
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
ARG PIP_VERSION
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
RUN python -m pip install -U pip==${PIP_VERSION}
RUN --mount=type=bind,from=build-image,source=/tmp/wheelhouse,target=/mnt/wheelhouse \
python -m pip install --no-index /mnt/wheelhouse/*.whl
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册