# 1. Base Image FROM python:3.11-slim # 2. Set environment variables to prevent permission issues ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Tell Streamlit and HF Hub to use a writable directory ENV STREAMLIT_HOME=/app/.streamlit ENV HF_HOME=/app/.cache/huggingface # 3. Install System Dependencies 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 CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true"]