From c7094b694f7b0bd4296a923be15b0ee7a479066d Mon Sep 17 00:00:00 2001 From: Vasanth Date: Tue, 27 Oct 2026 17:40:05 +0530 Subject: [PATCH] Docker: python slim + Debian chromium via CHROME_PATH mcr.microsoft.com Playwright image pulls get reset on the Dokploy server. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 13 +++++++++---- mek_recon.py | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c9df9d..57217d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,18 @@ -# Playwright image ships Chromium + its OS deps for this exact Playwright version -FROM mcr.microsoft.com/playwright/python:v1.49.0-noble +# python slim + Debian chromium: pulls of the mcr.microsoft.com Playwright image get reset on our +# Dokploy server (same fix as Capitation Amount Updater) +FROM python:3.12-slim + +RUN apt-get update \ + && apt-get install -y --no-install-recommends chromium fonts-liberation tzdata \ + && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . -# headless, bundled Chromium (no Google Chrome in the image) -ENV HEADLESS=1 CHROME_CHANNEL= PYTHONUNBUFFERED=1 TZ=America/New_York +# headless, system Chromium (Playwright's own browser download is not used) +ENV HEADLESS=1 CHROME_PATH=/usr/bin/chromium PYTHONUNBUFFERED=1 TZ=America/New_York EXPOSE 8000 # one worker: run state is kept in memory CMD ["gunicorn", "-w", "1", "--threads", "8", "-b", "0.0.0.0:8000", "--timeout", "120", "app:app"] diff --git a/mek_recon.py b/mek_recon.py index 1b98aa0..1b3d593 100644 --- a/mek_recon.py +++ b/mek_recon.py @@ -262,11 +262,14 @@ def run_site(site, locations): failed = [] seen = {} # file content -> location; two locations with identical exports = stale data with sync_playwright() as p: - # server/Docker: HEADLESS=1 and CHROME_CHANNEL="" (Playwright's bundled Chromium) + # server/Docker: HEADLESS=1 and CHROME_PATH=/usr/bin/chromium (Debian package) headless = os.environ.get("HEADLESS") == "1" + chrome_path = os.environ.get("CHROME_PATH") ctx = p.chromium.launch_persistent_context( str(ROOT / f".chrome_profile_{site.lower()}"), - channel=os.environ.get("CHROME_CHANNEL", "chrome") or None, headless=headless, + executable_path=chrome_path or None, + channel=None if chrome_path else os.environ.get("CHROME_CHANNEL", "chrome") or None, + headless=headless, accept_downloads=True, no_viewport=not headless, viewport={"width": 1440, "height": 900} if headless else None, )