Spaces:
Running
Running
| # 1. Use Hugging Face recommended Python image | |
| FROM python:3.12.8-slim | |
| # 2. Install system dependencies (as root) | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| libpq-dev \ | |
| curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 3. Upgrade pip & install Python dependencies system-wide (still root) | |
| COPY requirements.txt . | |
| RUN python -m pip install --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # 4. Install Playwright system dependencies (as root) | |
| RUN python -m playwright install-deps chromium | |
| # 5. Create non-root user (required by Hugging Face Spaces) | |
| RUN useradd -m -u 1000 user | |
| # 6. Switch to non-root user and install Playwright browsers into their home directory | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| RUN python -m playwright install chromium | |
| # 7. Set working directory | |
| WORKDIR /app | |
| # 8. Copy the rest of the app code | |
| COPY --chown=user . . | |
| # 9. Create the data directory (writable by user) | |
| RUN mkdir -p /app/data | |
| # 10. Expose Hugging Face default port | |
| EXPOSE 7860 | |
| # 11. Run Uvicorn server | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |