Spaces:
Paused
Paused
| FROM python:3.11-slim | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 \ | |
| PORT=7860 \ | |
| HOME=/home/user \ | |
| PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright \ | |
| PATH="/home/user/.local/bin:${PATH}" | |
| # Install Chromium system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| wget curl ca-certificates libglib2.0-0 libnss3 libnspr4 \ | |
| libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \ | |
| libxkbcommon0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 \ | |
| libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \ | |
| fonts-liberation fonts-noto-color-emoji \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create Hugging Face user (UID 1000) | |
| RUN useradd -m -u 1000 user && \ | |
| mkdir -p /home/user/app /home/user/.cache/ms-playwright && \ | |
| chown -R user:user /home/user | |
| WORKDIR /home/user/app | |
| # Install Python packages | |
| COPY --chown=user:user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Switch to user and download browser | |
| USER user | |
| RUN python -m patchright install chromium | |
| COPY --chown=user:user . . | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] |