Update Dockerfile
Browse files- Dockerfile +11 -11
Dockerfile
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
-
# Dockerfile for FastAPI + RAG
|
| 3 |
-
# Ensures /app/hf_cache is world-writable so Hugging Face can download models
|
| 4 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 5 |
|
| 6 |
FROM python:3.10-slim
|
| 7 |
|
| 8 |
-
# 1) Install system packages
|
| 9 |
RUN apt-get update && \
|
| 10 |
apt-get install -y --no-install-recommends \
|
| 11 |
build-essential \
|
|
@@ -14,29 +13,30 @@ RUN apt-get update && \
|
|
| 14 |
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
# 2) Copy
|
| 18 |
COPY requirements.txt .
|
| 19 |
|
| 20 |
-
# 3) Install PyTorch CPU
|
| 21 |
RUN pip install --upgrade pip && \
|
| 22 |
pip install --no-cache-dir torch==2.1.2+cpu --index-url https://download.pytorch.org/whl/cpu && \
|
| 23 |
pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
-
# 4)
|
| 26 |
-
RUN mkdir -p /app/hf_cache && chmod 777 /app/hf_cache
|
|
|
|
| 27 |
|
| 28 |
-
# 5)
|
| 29 |
ENV HF_HOME=/app/hf_cache
|
| 30 |
ENV TRANSFORMERS_CACHE=/app/hf_cache
|
| 31 |
ENV HF_DATASETS_CACHE=/app/hf_cache
|
| 32 |
ENV HF_METRICS_CACHE=/app/hf_cache
|
| 33 |
ENV SENTENCE_TRANSFORMERS_CACHE=/app/hf_cache
|
| 34 |
|
| 35 |
-
# 6) Copy the
|
| 36 |
COPY . .
|
| 37 |
|
| 38 |
-
# 7) Expose
|
| 39 |
EXPOSE 7860
|
| 40 |
|
| 41 |
-
# 8)
|
| 42 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
+
# Dockerfile for FastAPI + RAG (with pre-created writable chroma_db_users)
|
|
|
|
| 3 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
|
| 5 |
FROM python:3.10-slim
|
| 6 |
|
| 7 |
+
# 1) Install system packages for building any native extensions
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
build-essential \
|
|
|
|
| 13 |
|
| 14 |
WORKDIR /app
|
| 15 |
|
| 16 |
+
# 2) Copy requirements.txt first so pip layers can be cached
|
| 17 |
COPY requirements.txt .
|
| 18 |
|
| 19 |
+
# 3) Install PyTorch CPU + the rest of your Python deps
|
| 20 |
RUN pip install --upgrade pip && \
|
| 21 |
pip install --no-cache-dir torch==2.1.2+cpu --index-url https://download.pytorch.org/whl/cpu && \
|
| 22 |
pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
+
# 4) Pre-create the HF cache folder and chroma_db_users folder, and make them writable
|
| 25 |
+
RUN mkdir -p /app/hf_cache && chmod 777 /app/hf_cache && \
|
| 26 |
+
mkdir -p /app/chroma_db_users && chmod 777 /app/chroma_db_users
|
| 27 |
|
| 28 |
+
# 5) Tell all HuggingFace libs to use /app/hf_cache instead of .cache
|
| 29 |
ENV HF_HOME=/app/hf_cache
|
| 30 |
ENV TRANSFORMERS_CACHE=/app/hf_cache
|
| 31 |
ENV HF_DATASETS_CACHE=/app/hf_cache
|
| 32 |
ENV HF_METRICS_CACHE=/app/hf_cache
|
| 33 |
ENV SENTENCE_TRANSFORMERS_CACHE=/app/hf_cache
|
| 34 |
|
| 35 |
+
# 6) Copy the rest of your application code
|
| 36 |
COPY . .
|
| 37 |
|
| 38 |
+
# 7) Expose the default HF Spaces port (7860)
|
| 39 |
EXPOSE 7860
|
| 40 |
|
| 41 |
+
# 8) Launch Uvicorn against app.py (which defines `app = FastAPI()`)
|
| 42 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|