diff --git a/Dockerfile b/Dockerfile index cf62aaa..88e64e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV GITHUB_BUILD=${GITHUB_BUILD}\ WORKDIR /app RUN apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests xauth xvfb scrot curl chromium chromium-driver ca-certificates + apt-get install -y --no-install-recommends --no-install-suggests xauth xvfb scrot curl chromium chromium-driver ca-certificates tini ADD https://astral.sh/uv/install.sh install.sh RUN sh install.sh && uv --version @@ -44,4 +44,4 @@ RUN ./test.sh FROM app EXPOSE 8191 HEALTHCHECK --interval=15m --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "http://localhost:8191/health" ] -ENTRYPOINT ["uv", "run", "main.py"] +ENTRYPOINT ["/usr/bin/tini", "--", "uv", "run", "main.py"] diff --git a/src/utils.py b/src/utils.py index 1816247..34b87a8 100644 --- a/src/utils.py +++ b/src/utils.py @@ -27,14 +27,19 @@ def get_sb( detail="SOCKS5 proxy with authentication is not supported. Check README for more info.", ) - with SB( + sb_ctx = SB( uc=True, headless=USE_HEADLESS, locale_code="en", ad_block=True, proxy=proxy, - ) as sb: + ) + sb = sb_ctx.__enter__() + try: yield sb + finally: + sb_ctx.__exit__(None, None, None) + def save_screenshot(sb: BaseCase):