FROM python:3.10-slim # Create a user with UID 1000 RUN useradd -m -u 1000 user # Install system dependencies required for OpenCV RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* WORKDIR /home/user/app # Copy requirements and install COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy all application files with proper ownership COPY --chown=user . . # Switch to the non-root user USER user # Set environment variables for the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Hugging Face Spaces requires exposing port 7860 EXPOSE 7860 # Run uvicorn server on port 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]