From bbd0509d8b70539069d3a4d959d0292de3622c01 Mon Sep 17 00:00:00 2001 From: nfel Date: Tue, 4 Aug 2026 22:35:42 +0330 Subject: [PATCH] Install Python 3.12 + uv on Playwright Noble base image The Playwright image ships Ubuntu 24.04 + Chromium but no Python. This commit adds: - Ubuntu apt mirror (tuna) since ubuntu.com repos are blocked from Iran - python3 + python3-venv via apt - uv via curl installer - uv sync for project deps (targets Python 3.12) Admin stage stays on python:3.11-slim (no Chrome needed). Co-authored-by: Qwen-Coder --- Dockerfile | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b0b2b7..41732ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,24 +42,23 @@ EXPOSE 8000 CMD ["python", "main.py", "admin"] -# ── Stage 2b: worker runtime (Playwright Noble + Python) ────────────────────── -# Base image: oci.reg.darano.ir//mcr.microsoft.com/playwright:v1.62.0-noble -# This image already ships: -# - Ubuntu 24.04 LTS (Noble Numbat) -# - Chromium + matching ChromeDriver -# - Python 3.12 -# - ffmpeg, xvfb, and other browser utilities -# We only need to install our Python project dependencies. +# ── Stage 2b: worker runtime (Playwright Noble + Python installed) ───────────── +# Base: oci.reg.darano.ir//mcr.microsoft.com/playwright:v1.62.0-noble +# This image ships: Ubuntu 24.04 + Chromium + Firefox + WebKit + system libs. +# We add Python + uv ourselves. -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 -# The Playwright image ships Python via /usr/bin/python3 but pip is not in PATH. -# Install uv to manage our project dependencies. -# The Playwright Noble image includes a minimal uv shim at /usr/local/bin/uv — -# if it's not present, bootstrap it via curl. -RUN which uv >/dev/null 2>&1 || \ - (curl -LsSf https://astral.sh/uv/install.sh | \ - UV_INSTALL_DIR=/usr/local sh 2>&1 >/dev/null) +# Install Python 3.12 + uv (the Playwright image has browsers but no Python). +# Use a mirror for apt since the VPS has network restrictions (Iran). +# curl is already installed (playwright system dep). +RUN printf 'Types: deb\nURIs: https://mirrors.tuna.tsinghua.edu.cn/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 \ + && apt-get update && apt-get install -y --no-install-recommends \ + python3 python3-venv \ + && rm -rf /var/lib/apt/lists/* \ + && curl -LsSf https://astral.sh/uv/install.sh | \ + UV_INSTALL_DIR=/usr/local sh ENV PATH="/app/.venv/bin:$PATH" \ PYTHONUNBUFFERED=1 \