FROM python:3.10-slim # Install system dependencies for OpenCV USER root RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Create a user to avoid running as root (Required by Hugging Face) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy files and ensure the new user owns them COPY --chown=user . $HOME/app RUN pip install --no-cache-dir --user -r requirements.txt # Hugging Face Spaces always listens on port 7860 EXPOSE 7860 CMD ["python", "main.py"]