FROM python:3.10-slim WORKDIR /code # Set environment variable to disable pip cache ENV PIP_NO_CACHE_DIR=1 # Install system dependencies with cleanup RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ libgl1-mesa-glx \ libglib2.0-0 \ git \ && apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ rm -rf /tmp/* && \ mkdir -p /tmp && \ chmod 777 /tmp # Copy requirements first COPY requirements.txt . # Install dependencies with improved error handling RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir setuptools wheel && \ pip install --no-cache-dir -r requirements.txt || (echo "pip install failed" && exit 1) && \ rm -rf ~/.cache/pip && \ rm -rf /tmp/* && \ mkdir -p /tmp && \ chmod 777 /tmp # Copy application code COPY . . # Create necessary directories with proper permissions RUN mkdir -p /tmp/models/parts/weights/weights && \ chmod -R 777 /tmp EXPOSE 7860 # Added --reload flag for development convenience CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]