FROM python:3.9-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Copy project files COPY requirements.txt ./requirements.txt COPY src/ ./src/ COPY best.pt ./src/best.pt # Install Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Set environment variables for Streamlit and Ultralytics ENV HOME=/app ENV XDG_CONFIG_HOME=/app/.config ENV STREAMLIT_HOME=/app/.streamlit ENV STREAMLIT_CONFIG_DIR=/app/.streamlit ENV YOLO_CONFIG_DIR=/tmp # Create and configure Streamlit settings RUN mkdir -p /app/.streamlit && \ echo "\ [server]\n\ headless = true\n\ enableCORS = false\n\ enableXsrfProtection = false\n\ port = 7860\n\ \n\ [browser]\n\ gatherUsageStats = false\n\ " > /app/.streamlit/config.toml # Expose port expected by Hugging Face EXPOSE 7860 # Healthcheck (optional) HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1 # Run the Streamlit app ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]