Spaces:
Sleeping
Sleeping
File size: 1,048 Bytes
8db9436 9ca4520 8db9436 9ca4520 8db9436 9ca4520 8db9436 9ca4520 8db9436 9ca4520 8db9436 9ca4520 |
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 |
FROM python:3.11-slim
# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Python deps
COPY requirements.txt /app/
ENV PIP_NO_CACHE_DIR=1
RUN pip install --no-cache-dir -r requirements.txt
# App
COPY main.py /app/
# Set a sane HOME and Hugging Face caches to a writable, persistent location
ENV HOME=/app
ENV MODEL_NAME=BAAI/bge-small-en-v1.5
ENV TZ=America/New_York
# Hugging Face cache locations (avoid '/.cache' permission issues)
ENV MODEL_CACHE_DIR=/data/.cache
ENV HF_HOME=/data/.cache/huggingface
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers
ENV SENTENCE_TRANSFORMERS_HOME=/data/.cache/sentence-transformers
# Ensure cache dirs exist and are writable
RUN mkdir -p /data/.cache/huggingface/transformers /data/.cache/sentence-transformers && \
chmod -R 777 /data
# Expose server port (Spaces sets $PORT)
ENV PORT=7860
EXPOSE 7860
# Run
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 1"]
|