FROM python:3.10 # Set the working directory WORKDIR /app # Set environment variables for Hugging Face cache location ENV TRANSFORMERS_CACHE=/app/models_cache ENV HF_HOME=/app/models_cache ENV HF_DATASETS_CACHE=/app/models_cache ENV SENTENCE_TRANSFORMERS_HOME=/app/models_cache ENV XDG_CACHE_HOME=/app/models_cache # Copy and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the application code COPY . . # Ensure the models_cache directory exists and set permissions RUN mkdir -p /app/models_cache && chmod -R 777 /app/models_cache # Expose port 7860 EXPOSE 7860 # Run the FastAPI application with Uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]