mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2026-09-24 14:20:08 +01:00
Measuring the widget with page.evaluate() made Cloudflare reissue the challenge every few seconds, so the interstitial never cleared. Locate the container with locators instead and click it through the mouse, which leaves its closed shadow root untouched. Keep the solver lazy as well: ClickSolver.prepare() patches attachShadow, which is what escalated a self-clearing challenge into a checkbox in the first place. A click can land while the widget is still self-verifying, so retry on a cooldown for as long as the request budget lasts rather than stopping after the first one, and confirm the marker is gone twice before reporting success since it drops out between challenge rounds. The bypass tests now pass on their own, so drop the xfail marks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
63 lines
1.7 KiB
Docker
63 lines
1.7 KiB
Docker
# Ubuntu is required by playwright.
|
|
# Pin to 24.04 LTS: ubuntu:latest floats to 26.04, which Playwright 1.58
|
|
# cannot install firefox deps for (no libgtk-3 -> camoufox fails to launch).
|
|
FROM ubuntu:24.04 AS base
|
|
|
|
ARG GITHUB_BUILD=false
|
|
|
|
ENV GITHUB_BUILD=${GITHUB_BUILD}\
|
|
PYTHONUNBUFFERED=1 \
|
|
# prevents python creating .pyc files
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
PORT=8191 \
|
|
XDG_CACHE_HOME=/cache \
|
|
HOME=/home/byparr
|
|
|
|
RUN apt-get update &&\
|
|
apt-get install -y --no-install-recommends curl ca-certificates git tini &&\
|
|
apt-get clean &&\
|
|
rm -rf /var/lib/apt/lists/*
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
|
|
|
FROM base AS devcontainer
|
|
RUN apt-get update &&\
|
|
apt-get install -y --no-install-recommends git &&\
|
|
uvx playwright install-deps firefox &&\
|
|
uvx --from git+https://github.com/feder-cr/invisible_playwright.git python -m invisible_playwright fetch &&\
|
|
apt-get clean &&\
|
|
rm -rf /var/lib/apt/lists/*
|
|
ENTRYPOINT [ "sleep", "infinity" ]
|
|
|
|
FROM base AS app
|
|
WORKDIR /app
|
|
|
|
COPY pyproject.toml uv.lock ./
|
|
RUN mkdir -p /cache &&\
|
|
uv sync &&\
|
|
uv run python -m invisible_playwright fetch &&\
|
|
apt-get update &&\
|
|
uv run playwright install-deps firefox &&\
|
|
uv cache clean &&\
|
|
apt-get clean &&\
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY . .
|
|
|
|
RUN mkdir -p /home/byparr &&\
|
|
chmod -R o+rX /app &&\
|
|
chmod -R a+rwX /cache /home/byparr
|
|
|
|
FROM app AS test
|
|
RUN \
|
|
uv sync --group test &&\
|
|
uv run pytest -rs --retries 5
|
|
|
|
FROM app
|
|
ARG VERSION
|
|
ENV VERSION=${VERSION}
|
|
USER 1000
|
|
EXPOSE $PORT
|
|
HEALTHCHECK --interval=15m --timeout=30s --start-period=5s --retries=3 CMD curl "http://127.0.0.1:${PORT}/health"
|
|
ENTRYPOINT ["tini", "--", "/app/.venv/bin/python", "main.py"]
|