FROM python:3.9-slim # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Create cache directories and ensure permissions RUN mkdir -p /tmp/.cache/huggingface && \ mkdir -p /tmp/.cache/nltk && \ chmod -R a+rwx /tmp/.cache # Set the environment variable for transformers cache directory ENV TRANSFORMERS_CACHE=/tmp/.cache/huggingface WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Download NLTK data to cache RUN python -c "import nltk; nltk.download('punkt', download_dir='/tmp/.cache/nltk')" COPY . . EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]