FROM python:3.10-slim # HuggingFace Spaces runs as a non-root user RUN useradd -m -u 1000 user WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ supervisor \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy project files COPY --chown=user:user . . # Supervisor config to run both FastAPI and Streamlit COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf USER user # HF Spaces expects port 7860 EXPOSE 7860 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]