fix(docker): rewrite agentsmirror lock URLs and refresh numpy

uv.lock uses uv.agentsmirror.com paths that the old sed rules never matched,
which could install corrupted wheels from cache. Rewrite to Tsinghua mirrors,
force-refresh numpy/mediapipe, and verify numpy imports during the image build.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin
2026-05-22 17:39:28 +08:00
parent 3de34fb79c
commit aae0340a1b

View File

@@ -51,11 +51,11 @@ COPY alembic ./alembic/
# 离线批处理 / demo 直调 algorithm_subprocesses/5.15/main.py含 weights/ # 离线批处理 / demo 直调 algorithm_subprocesses/5.15/main.py含 weights/
COPY algorithm_subprocesses ./algorithm_subprocesses/ COPY algorithm_subprocesses ./algorithm_subprocesses/
# uv.lock pins full download URLs. Rewrite to mainland-accessible mirrors (same paths / hashes). # uv.lock pins uv.agentsmirror.com artifact URLs. Rewrite to mainland mirrors (same /packages/... paths).
# PyPI: Tsinghua | PyTorch wheel index: 南大 (syncs download.pytorch.org / download-r2) # PyPI: Tsinghua | PyTorch wheel index: 南大 (syncs download.pytorch.org / download-r2)
RUN sed -i \ RUN sed -i \
-e 's|https://files.pythonhosted.org|https://pypi.tuna.tsinghua.edu.cn|g' \ -e 's|https://uv.agentsmirror.com/pypi/files/files.pythonhosted.org|https://pypi.tuna.tsinghua.edu.cn|g' \
-e 's|https://pypi.org/simple|https://pypi.tuna.tsinghua.edu.cn/simple|g' \ -e 's|https://uv.agentsmirror.com/pypi/simple|https://pypi.tuna.tsinghua.edu.cn/simple|g' \
-e 's|https://download-r2.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \ -e 's|https://download-r2.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \
-e 's|https://download.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \ -e 's|https://download.pytorch.org|https://mirrors.nju.edu.cn/pytorch|g' \
uv.lock uv.lock
@@ -63,8 +63,9 @@ RUN sed -i \
ENV UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple ENV UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev && \ uv sync --frozen --no-dev --refresh-package numpy --refresh-package mediapipe && \
.venv/bin/python -c "import alembic" && \ .venv/bin/python -c "import alembic" && \
.venv/bin/python -c "import numpy; import numpy.lib._index_tricks_impl" && \
.venv/bin/python -c "import mediapipe as mp; print('mediapipe', mp.__version__)" .venv/bin/python -c "import mediapipe as mp; print('mediapipe', mp.__version__)"
ENV PATH="/app/.venv/bin:$PATH" ENV PATH="/app/.venv/bin:$PATH"