FROM python:3.11-slim # Install system dependencies for OpenCV and ML RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxrender1 \ libxext6 \ curl \ && rm -rf /var/lib/apt/lists/* # Set up user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /home/user/app # Force Keras 2 for TensorFlow 2.15 compatibility ENV TF_USE_LEGACY_KERAS=1 # Install Python dependencies COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip RUN pip install --no-cache-dir -r requirements.txt # Copy source code COPY --chown=user . . # Hugging Face Spaces typically expects port 7860 EXPOSE 7860 # Environment variable for Hugging Face ENV GRADIO_SERVER_NAME="0.0.0.0" ENV GRADIO_SERVER_PORT="7860" # Make startup script executable RUN chmod +x start.sh # Run the startup script for better debugging CMD ["./start.sh"]