Download uv binary directly from GitHub releases instead of install script

The install script puts binaries in unexpected places and the shell
used in RUN (dash) doesn't have /usr/local/bin in PATH. Downloading
the pre-built binary directly from GitHub releases and extracting
it to /usr/local/bin/ where it's immediately accessible.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-08-04 22:49:55 +03:30
parent 776de685d0
commit e222ffdcc4
+9 -10
View File
@@ -12,17 +12,17 @@ ARG BASE_IMAGE=python:3.11-slim
# ── Stage 1: dependency resolver ───────────────────────────────────────────── # ── Stage 1: dependency resolver ─────────────────────────────────────────────
FROM python:3.11-slim AS builder FROM python:3.11-slim AS builder
# Install uv via curl (not pip) to avoid any PyPI/network dependency
RUN curl -LsSf https://astral.sh/uv/install.sh | \
UV_INSTALL_DIR=/usr/local sh
WORKDIR /app WORKDIR /app
# Download the uv binary directly from GitHub releases (no install script quirks)
RUN curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz \
| tar xz -C /usr/local/bin
ENV UV_INDEX_URL="http://pypi.reg.darano.ir/simple/" ENV UV_INDEX_URL="http://pypi.reg.darano.ir/simple/"
COPY pyproject.toml uv.lock* ./ COPY pyproject.toml uv.lock* ./
RUN /usr/local/uv/bin/uv sync --frozen --no-dev --no-install-project RUN /usr/local/bin/uv sync --frozen --no-dev --no-install-project
# ── Stage 2a: admin runtime (python:3.11-slim, no Chrome needed) ────────────── # ── Stage 2a: admin runtime (python:3.11-slim, no Chrome needed) ──────────────
FROM ${BASE_IMAGE} AS admin FROM ${BASE_IMAGE} AS admin
@@ -54,17 +54,16 @@ CMD ["python", "main.py", "admin"]
FROM oci.reg.darano.ir/mcr.microsoft.com/playwright:v1.62.0-noble AS worker FROM oci.reg.darano.ir/mcr.microsoft.com/playwright:v1.62.0-noble AS worker
# Install Python 3.12 + uv, then sync deps — all in one RUN so PATH is consistent. # Install Python 3.12 + uv, then sync deps — all in one RUN.
# Use a mirror for apt since the VPS has network restrictions (Iran). # Use a mirror for apt since the VPS has network restrictions (Iran).
# curl is already installed (playwright system dep). # Download uv binary directly (not via install script which is unreliable in Docker).
RUN printf 'Types: deb\nURIs: http://repo.iut.ac.ir/ubuntu/\nSuites: noble noble-updates noble-security\nComponents: main restricted universe multiverse\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \ RUN printf 'Types: deb\nURIs: http://repo.iut.ac.ir/ubuntu/\nSuites: noble noble-updates noble-security\nComponents: main restricted universe multiverse\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
> /etc/apt/sources.list.d/ubuntu.sources \ > /etc/apt/sources.list.d/ubuntu.sources \
&& apt-get update && apt-get install -y --no-install-recommends \ && apt-get update && apt-get install -y --no-install-recommends \
python3 python3-venv \ python3 python3-venv \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& curl -LsSf https://astral.sh/uv/install.sh | \ && curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz \
UV_INSTALL_DIR=/usr/local sh \ | tar xz -C /usr/local/bin
&& /usr/local/uv/bin/uv sync --frozen --no-dev --no-install-project
ENV PATH="/app/.venv/bin:$PATH" \ ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \