FROM python:3.11-slim RUN useradd -m -u 1000 user WORKDIR /app # System deps for Crawl4AI's Playwright (lean install) RUN apt-get update && apt-get install -y --no-install-recommends \ wget gnupg ca-certificates \ && rm -rf /var/lib/apt/lists/* COPY --chown=user requirements.txt /app/requirements.txt # CPU-only PyTorch (HF Spaces has no GPU; default PyPI torch pulls huge CUDA stacks) RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu \ && pip install --no-cache-dir -r /app/requirements.txt # Install Playwright Chromium (Crawl4AI uses it) RUN python -m playwright install --with-deps chromium COPY --chown=user . /app USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]