Spaces:
Sleeping
Sleeping
File size: 1,166 Bytes
3434ef3 a5a6099 3434ef3 a5a6099 3434ef3 a5a6099 3434ef3 a5a6099 3434ef3 |
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 |
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"]
|