FROM python:3.10-slim # Set working directory WORKDIR /app # Set environment variables for matplotlib and ultralytics ENV MPLCONFIGDIR=/tmp/matplotlib ENV YOLO_CONFIG_DIR=/app/.config/ultralytics ENV FONTCONFIG_PATH=/tmp/fontconfig ENV HOME=/app # Install system dependencies including ffmpeg RUN apt-get update && apt-get install -y \ ffmpeg \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libglib2.0-0 \ fontconfig \ && rm -rf /var/lib/apt/lists/* # Create writable directories for cache and config RUN mkdir -p /tmp/matplotlib /tmp/fontconfig /app/.config/ultralytics \ && chmod -R 777 /tmp /app/.config # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY . . # Create necessary directories with proper permissions RUN mkdir -p audio temp \ && chmod -R 777 /app # Download YOLO model RUN python download_model.py EXPOSE 7860 # Run the application on correct host/port CMD ["uvicorn", "link2:app", "--host", "0.0.0.0", "--port", "7860"]