Spaces:
Sleeping
Sleeping
| 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"] | |