Fix worker rq not found — build venv natively in Playwright image
The Playwright Noble image ships Python 3.12 while the builder uses python:3.11-slim. Copying the venv produced broken shebangs, causing "exec /app/.venv/bin/rq: no such file or directory". Fix: install uv in the worker stage and run uv sync natively so the venv targets this image's Python version. Manifests copied first for layer cache efficiency. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
+10
-4
@@ -49,6 +49,8 @@ EXPOSE 8000
|
|||||||
CMD ["python", "main.py", "admin"]
|
CMD ["python", "main.py", "admin"]
|
||||||
|
|
||||||
# ── Stage 2b: worker runtime (Playwright image with Chromium) ────────────────
|
# ── Stage 2b: worker runtime (Playwright image with Chromium) ────────────────
|
||||||
|
# The Playwright Noble image ships Python 3.12. Copying a venv built with
|
||||||
|
# python:3.11-slim would produce broken shebangs — so we build the venv here.
|
||||||
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
|
||||||
|
|
||||||
ENV PATH="/app/.venv/bin:$PATH" \
|
ENV PATH="/app/.venv/bin:$PATH" \
|
||||||
@@ -62,11 +64,15 @@ ENV PATH="/app/.venv/bin:$PATH" \
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy application code
|
# Copy manifests + lockfile first (stable cache layer)
|
||||||
COPY . .
|
COPY pyproject.toml uv.lock* ./
|
||||||
|
|
||||||
# Copy Python deps from builder stage
|
# Install deps natively so the venv targets this image's Python
|
||||||
COPY --from=builder /app/.venv /app/.venv
|
RUN pip install --no-cache-dir --upgrade uv==0.11.31 \
|
||||||
|
&& uv sync --frozen --no-dev --no-install-project
|
||||||
|
|
||||||
|
# Copy app code (busts cache on code changes, not deps)
|
||||||
|
COPY . .
|
||||||
|
|
||||||
# Playwright's Chromium is already downloaded and pre-patched with
|
# Playwright's Chromium is already downloaded and pre-patched with
|
||||||
# undetected-chromedriver-friendly modifications, so no patch_driver run needed.
|
# undetected-chromedriver-friendly modifications, so no patch_driver run needed.
|
||||||
|
|||||||
Reference in New Issue
Block a user