FROM python:3.10-slim WORKDIR /app # Install system deps RUN apt-get update && apt-get install -y --no-install-recommends \ libglib2.0-0 libsm6 libxrender1 libxext6 git \ && rm -rf /var/lib/apt/lists/* # Copy and install Python deps first (layer cache) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy source COPY pyproject.toml . COPY src/ src/ COPY app.py . # Install the package RUN pip install --no-cache-dir -e . # HF Spaces runs as non-root user 1000 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH EXPOSE 7860 CMD ["python", "app.py"]