Spaces:
Sleeping
Sleeping
| # ===== Hugging Face Spaces: Playwright + Chromium (stable) ===== | |
| FROM python:3.11-slim | |
| # System deps cho Chromium | |
| RUN apt-get update && apt-get install -y \ | |
| wget gnupg unzip curl git \ | |
| fonts-liberation libnss3 libxkbcommon0 libatk-bridge2.0-0 \ | |
| libxcomposite1 libxrandr2 libxdamage1 libxext6 libdrm2 libgbm1 \ | |
| libasound2 libpango-1.0-0 libpangocairo-1.0-0 libgtk-3-0 \ | |
| libxshmfence1 libglib2.0-0 libxml2 libxslt1.1 libffi-dev libssl-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Chọn nơi cài browsers PERSISTENT trong image (không dùng /root/.cache) | |
| ENV PLAYWRIGHT_BROWSERS_PATH=/usr/local/share/pw-browsers | |
| # Chú ý: lúc build ta cần tải browsers, nên KHÔNG set SKIP=1 ở đây | |
| WORKDIR /app | |
| COPY . . | |
| # Python deps + Playwright + tải Chromium NGAY TRONG BUILD | |
| RUN pip install --no-cache-dir -r requirements.txt \ | |
| && pip install --no-cache-dir playwright \ | |
| && python -m playwright install --with-deps chromium \ | |
| && chmod -R a+rX /usr/local/share/pw-browsers | |
| # Khi runtime, KHÔNG tải lại browsers | |
| ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | |
| CMD ["python", "app.py"] | |