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 <qwen-coder@alibabacloud.com>
This commit is contained in:
+15
-16
@@ -42,24 +42,23 @@ EXPOSE 8000
|
|||||||
|
|
||||||
CMD ["python", "main.py", "admin"]
|
CMD ["python", "main.py", "admin"]
|
||||||
|
|
||||||
# ── Stage 2b: worker runtime (Playwright Noble + Python) ──────────────────────
|
# ── Stage 2b: worker runtime (Playwright Noble + Python installed) ─────────────
|
||||||
# Base image: oci.reg.darano.ir//mcr.microsoft.com/playwright:v1.62.0-noble
|
# Base: oci.reg.darano.ir//mcr.microsoft.com/playwright:v1.62.0-noble
|
||||||
# This image already ships:
|
# This image ships: Ubuntu 24.04 + Chromium + Firefox + WebKit + system libs.
|
||||||
# - Ubuntu 24.04 LTS (Noble Numbat)
|
# We add Python + uv ourselves.
|
||||||
# - Chromium + matching ChromeDriver
|
|
||||||
# - Python 3.12
|
|
||||||
# - ffmpeg, xvfb, and other browser utilities
|
|
||||||
# We only need to install our Python project dependencies.
|
|
||||||
|
|
||||||
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 Python 3.12 + uv (the Playwright image has browsers but no Python).
|
||||||
# Install uv to manage our project dependencies.
|
# Use a mirror for apt since the VPS has network restrictions (Iran).
|
||||||
# The Playwright Noble image includes a minimal uv shim at /usr/local/bin/uv —
|
# curl is already installed (playwright system dep).
|
||||||
# if it's not present, bootstrap it via curl.
|
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' \
|
||||||
RUN which uv >/dev/null 2>&1 || \
|
> /etc/apt/sources.list.d/ubuntu.sources \
|
||||||
(curl -LsSf https://astral.sh/uv/install.sh | \
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||||
UV_INSTALL_DIR=/usr/local sh 2>&1 >/dev/null)
|
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" \
|
ENV PATH="/app/.venv/bin:$PATH" \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
|
|||||||
Reference in New Issue
Block a user