FROM python:3.9-slim # Install system dependencies required for OpenCV RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy the requirements file and install dependencies COPY --chown=user requirements_web.txt . RUN pip install --no-cache-dir -r requirements_web.txt gunicorn # Copy the rest of the application COPY --chown=user . . # Expose port 7860 (Hugging Face Spaces default port) EXPOSE 7860 # Command to run the Flask application using Gunicorn CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "120", "--workers", "1", "--threads", "2", "app:app"]