FROM python:3.9-slim # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1-mesa-glx \ libglib2.0-0 \ wget \ git \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create directories for models RUN mkdir -p weights/icon_detect weights/icon_caption_florence # Copy application code COPY main.py utils.py download_models.py ./ # Download models during build RUN python download_models.py # Set up user for HF Spaces RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Run the application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]