# Use official Python image FROM python:3.10 # Set working directory WORKDIR / # Copy project files COPY . . # Define writable cache locations # Setup all huggingface and nltk cache dirs to writable /tmp ENV HF_HOME=/tmp/hf_home ENV TRANSFORMERS_CACHE=/tmp/hf_home ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_home ENV HF_HUB_ENABLE_HF_TRANSFER=0 ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1 ENV HF_HUB_DISABLE_XET=1 ENV NLTK_DATA=/tmp/nltk_data # Create required directories and ensure proper permissions RUN mkdir -p /tmp/hf_home/models /tmp/hf_home/hub /tmp/nltk_data /tmp/reports && \ chmod -R 777 /tmp/hf_home /tmp/nltk_data /tmp/reports # Optional: expose as env variable ENV REWRITTEN_OUTPUTS_DIR=/tmp/rewritten_outputs # Install dependencies RUN pip install --upgrade pip RUN pip install -r requirements.txt # Download NLTK tokenizer RUN python -m nltk.downloader punkt -d /tmp/nltk_data # Expose port EXPOSE 7860 # Start FastAPI server CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]