FROM python:3.10-slim ENV PYTHONUNBUFFERED=1 # Replace TRANSFORMERS_CACHE with HF_HOME ENV HF_HOME=/app/cache ENV UPLOAD_DIR=/app/uploads ENV NLTK_DATA=/tmp/nltk_data ENV PORT=7860 # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ gcc \ python3-dev \ libmagic1 \ libmupdf-dev \ poppler-utils \ && rm -rf /var/lib/apt/lists/* # Create directories and set permissions RUN mkdir -p /app/cache /app/uploads /app/static /app/images /tmp/nltk_data && \ chmod -R 777 /app /tmp/nltk_data WORKDIR /app # Copy and install requirements COPY requirements.txt . RUN pip install --no-cache-dir -U pip setuptools wheel && \ pip install --no-cache-dir -r requirements.txt # Clear cache to avoid conflicts with model names RUN rm -rf /app/cache/* && \ chmod -R 777 /app/cache # Copy application code COPY . . # Expose port EXPOSE 7860 # Healthcheck HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]