Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +17 -6
Dockerfile
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# Hugging Face Space (Docker) — FastAPI + sentence-transformers
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# System deps
|
|
@@ -7,7 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
# Python deps
|
| 11 |
COPY requirements.txt /app/
|
| 12 |
ENV PIP_NO_CACHE_DIR=1
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
@@ -15,13 +14,25 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 15 |
# App
|
| 16 |
COPY main.py /app/
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
ENV
|
| 20 |
ENV MODEL_NAME=BAAI/bge-small-en-v1.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
ENV PORT=7860
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
-
# Run
|
| 27 |
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 1"]
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
# System deps
|
|
|
|
| 6 |
|
| 7 |
WORKDIR /app
|
| 8 |
|
| 9 |
+
# Python deps
|
| 10 |
COPY requirements.txt /app/
|
| 11 |
ENV PIP_NO_CACHE_DIR=1
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 14 |
# App
|
| 15 |
COPY main.py /app/
|
| 16 |
|
| 17 |
+
# Set a sane HOME and Hugging Face caches to a writable, persistent location
|
| 18 |
+
ENV HOME=/app
|
| 19 |
ENV MODEL_NAME=BAAI/bge-small-en-v1.5
|
| 20 |
+
ENV TZ=America/New_York
|
| 21 |
+
|
| 22 |
+
# Hugging Face cache locations (avoid '/.cache' permission issues)
|
| 23 |
+
ENV MODEL_CACHE_DIR=/data/.cache
|
| 24 |
+
ENV HF_HOME=/data/.cache/huggingface
|
| 25 |
+
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers
|
| 26 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/data/.cache/sentence-transformers
|
| 27 |
|
| 28 |
+
# Ensure cache dirs exist and are writable
|
| 29 |
+
RUN mkdir -p /data/.cache/huggingface/transformers /data/.cache/sentence-transformers && \
|
| 30 |
+
chmod -R 777 /data
|
| 31 |
+
|
| 32 |
+
# Expose server port (Spaces sets $PORT)
|
| 33 |
ENV PORT=7860
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Run
|
| 37 |
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 1"]
|
| 38 |
+
|