Bootstrap pip via ensurepip in builder stage

python:3.11-slim has neither curl nor pip. Using ensurepip to get
pip, then pip install uv from the local registry mirror. This avoids
any network dependency on pypi.org or astral.sh.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-08-04 23:00:32 +03:30
parent 5001a8f2e8
commit 2e507cf5fa
+8 -5
View File
@@ -14,12 +14,15 @@ FROM python:3.11-slim AS builder
WORKDIR /app
# Install uv — download the pre-built binary directly from GitHub releases
# and add it to PATH for this layer.
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
&& . /usr/local/env 2>/dev/null || true
# python:3.11-slim has neither curl nor pip. Bootstrap pip via ensurepip,
# then use it to install uv from the local PyPI mirror.
RUN python -m ensurepip --upgrade \
&& python -m pip install --break-system-packages \
--index-url https://pypi.reg.darano.ir/simple/ \
--trusted-host pypi.reg.darano.ir \
uv
ENV PATH="/root/.local/bin:$PATH" \
ENV PATH="/usr/local/bin:$PATH" \
UV_DEFAULT_INDEX="https://pypi.reg.darano.ir"
COPY pyproject.toml uv.lock* ./