Spaces:
Sleeping
Sleeping
File size: 1,010 Bytes
d090749 ebb658b d090749 19d0c12 d090749 35558d9 ebb658b d090749 2201cf8 19d0c12 e09b7cc 2201cf8 71e286b 19d0c12 af4e7c9 94b6aa4 19d0c12 d090749 5aca8ca ebb658b d090749 71e286b c885844 d090749 19d0c12 d090749 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # 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"]
|