# 1. Base Image FROM python:3.11-slim # 2. Set environment variables for a non-interactive server ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # 3. Install the single critical system dependency for OpenCV RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ && rm -rf /var/lib/apt/lists/* # 4. Set the working directory WORKDIR /app # 5. Copy and install Python requirements COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 6. Copy the rest of the application COPY . . # 7. Expose the correct Hugging Face Space port EXPOSE 7860 # 8. Entrypoint with all necessary flags to prevent permission and connection errors CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true"]