FROM python:3.11-slim # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ git \ ffmpeg \ libsm6 \ libxext6 \ poppler-utils \ && rm -rf /var/lib/apt/lists/* # Create user for Hugging Face Spaces (UID 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 \ MPLBACKEND=Agg \ HF_HUB_DISABLE_TELEMETRY=1 \ DO_NOT_TRACK=1 WORKDIR $HOME/app # Install Python requirements COPY --chown=user:user requirements.txt $HOME/app/requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application source code COPY --chown=user:user . $HOME/app # Ensure user_data directory is writable RUN mkdir -p $HOME/app/user_data && chmod -R 777 $HOME/app/user_data EXPOSE 7860 CMD ["uvicorn", "backend.web_api:app", "--host", "0.0.0.0", "--port", "7860"]