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 \