FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Copy requirements file COPY requirements.txt . # Install PyTorch with CPU-specific index RUN pip install --no-cache-dir torch==2.4.0 --index-url https://download.pytorch.org/whl/cpu # Install remaining dependencies RUN pip install --no-cache-dir -r requirements.txt # Create cache directory with write permissions RUN mkdir -p /app/cache/hub && chmod -R 777 /app/cache # Copy application code COPY app.py . # Set environment variables ENV HF_HOME=/app/cache ENV NUMBA_CACHE_DIR=/app/cache # Expose port EXPOSE 7860 # Run FastAPI with Uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]