Spaces:
Sleeping
Sleeping
| FROM python:3.10 | |
| WORKDIR /code | |
| # Create cache directories with proper permissions and ownership | |
| RUN mkdir -p /tmp/cache/huggingface && \ | |
| mkdir -p /tmp/cache/transformers && \ | |
| mkdir -p /tmp/cache/sentence_transformers && \ | |
| chmod -R 777 /tmp/cache && \ | |
| chown -R 1000:1000 /tmp/cache | |
| # Set environment variables for cache directories | |
| ENV HF_HOME=/tmp/cache/huggingface | |
| ENV TRANSFORMERS_CACHE=/tmp/cache/transformers | |
| ENV SENTENCE_TRANSFORMERS_HOME=/tmp/cache/sentence_transformers | |
| ENV TORCH_HOME=/tmp/cache/torch | |
| ENV XDG_CACHE_HOME=/tmp/cache | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Pre-download the sentence transformer model during build with proper cache setup | |
| RUN export HF_HOME=/tmp/cache/huggingface && \ | |
| export TRANSFORMERS_CACHE=/tmp/cache/transformers && \ | |
| export SENTENCE_TRANSFORMERS_HOME=/tmp/cache/sentence_transformers && \ | |
| python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" && \ | |
| chmod -R 777 /tmp/cache | |
| COPY . /code | |
| CMD ["uvicorn", "fapi:app", "--host", "0.0.0.0", "--port", "7860"] | |