FROM python:3.10-slim ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 WORKDIR /app # Install minimal build tools (some packages require compilation) RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ build-essential \ gcc \ ca-certificates \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ && rm -rf /var/lib/apt/lists/* # Install Python deps (cache layer) COPY requirements.txt . RUN pip install --upgrade pip setuptools wheel && pip install -r requirements.txt # Create a non-root user and set ownership RUN useradd -m appuser && mkdir -p /app USER appuser # Copy application code COPY --chown=appuser:appuser . . # Hugging Face Spaces expects the web process to listen on the provided PORT (defaults to 7860) EXPOSE 7860 # Use PORT env if set by Spaces, default to 7860; include proxy headers for correct client IPs CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860} --proxy-headers"]