Spaces:
Runtime error
Runtime error
File size: 1,061 Bytes
18ac8b6 4915e22 18ac8b6 4915e22 2b5b95f 18ac8b6 4915e22 2b5b95f 18ac8b6 4915e22 18ac8b6 4915e22 18ac8b6 |
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 |
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory
WORKDIR /app
# Create a writable cache directory
RUN mkdir -p /app/cache
# Set environment variables for Hugging Face cache
ENV HF_HOME="/app/cache"
ENV TRANSFORMERS_CACHE="/app/cache"
ENV SENTENCE_TRANSFORMERS_HOME="/app/cache"
# Copy requirements.txt and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Force model download during build (ensures model is available inside container)
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', cache_folder='/app/cache')"
RUN python -c "from transformers import AutoModelForSeq2SeqLM; AutoModelForSeq2SeqLM.from_pretrained('google/long-t5-tglobal-base', cache_dir='/app/cache')"
# Copy the entire app into the container
COPY . .
# Expose the port FastAPI will run on
EXPOSE 7860
# Run the FastAPI app with Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|