FROM python:3.9 WORKDIR /app # Create a writable cache directory RUN mkdir -p /app/.cache && chmod 777 /app/.cache # Set environment variables for cache ENV HF_HOME=/app/.cache ENV TRANSFORMERS_CACHE=/app/.cache/transformers ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers ENV TORCH_HOME=/app/.cache/torch # Install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Download NLTK data RUN python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')" # Copy all files COPY . . # Create data directory if needed RUN mkdir -p data # Expose port EXPOSE 7860 # Run Flask app CMD ["python", "run.py"]