FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1-mesa-glx \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -u 1000 user USER user # Set environment variables for writable config directories ENV MPLCONFIGDIR=/home/user/.cache/matplotlib ENV YOLO_CONFIG_DIR=/home/user/.config/Ultralytics # Create the necessary directories RUN mkdir -p ${MPLCONFIGDIR} ${YOLO_CONFIG_DIR} # Copy and install Python dependencies COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the project files COPY --chown=user:user . . # Expose the port Gradio will run on EXPOSE 7860 # Start the Gradio app CMD ["python", "app.py"]