FROM python:3.10-slim RUN useradd -m -u 1000 user USER root RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 \ && rm -rf /var/lib/apt/lists/* USER user ENV PATH="/home/user/.local/bin:$PATH" # Force Python to print immediately — critical for HF health checks ENV PYTHONUNBUFFERED=1 WORKDIR /app COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY --chown=user server.py . COPY --chown=user models/ ./models/ EXPOSE 7860 CMD ["python", "server.py"]