# Use the official Python 3.13 slim image for a lightweight base FROM python:3.13.2 # Set the working directory to /app WORKDIR /app # Copy only requirements.txt first to leverage Docker caching COPY requirements.txt . # Install dependencies from requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application files COPY . . # Create cache directories and set permissions RUN mkdir -p /tmp/huggingface_cache && chmod -R 777 /tmp/huggingface_cache && rm -rf /tmp/huggingface_cache/* # Set environment variable for Transformers cache ENV HF_HOME=/tmp/huggingface_cache # Expose port 7860 for Hugging Face Spaces EXPOSE 7860 # Start the FastAPI app with Uvicorn on port 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]