# Use Python 3.10 FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set working directory WORKDIR /app # Install system libraries (including libgl1 for OpenCV) RUN apt-get update && apt-get install -y \ libglib2.0-0 \ libgomp1 \ libgl1 \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (Hugging Face requirement) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Copy requirements first to cache dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application COPY --chown=user . /app # Hugging Face expects the app to listen on port 7860 EXPOSE 7860 # Run the Flask app CMD ["python", "app.py"]