fix: set HF_HOME to /app/.cache so user 1000 can read baked reranker weights
Browse filesBuild-time pre-download ran as root β cached in /root/.cache/huggingface.
Runtime user 1000 looked in /home/user/.cache β not found β HF_HUB_OFFLINE blocked download β crash.
Fix: set HF_HOME=/app/.cache/huggingface before pre-download step (after USER 1000),
so weights are written to and read from the same /app-owned path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Dockerfile +5 -4
Dockerfile
CHANGED
|
@@ -7,9 +7,6 @@ COPY requirements.txt .
|
|
| 7 |
RUN pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
-
# Bake reranker weights into image β avoids cold-start HF Hub download
|
| 11 |
-
RUN python -c "from sentence_transformers import CrossEncoder; CrossEncoder('cross-encoder/ms-marco-TinyBERT-L-2-v2')"
|
| 12 |
-
|
| 13 |
COPY server/ server/
|
| 14 |
COPY config.yaml .
|
| 15 |
COPY data/ground_truth/ data/ground_truth/
|
|
@@ -20,10 +17,14 @@ RUN mkdir -p data/raw logs chroma_db
|
|
| 20 |
RUN useradd -m -u 1000 user && chown -R user /app
|
| 21 |
USER user
|
| 22 |
|
| 23 |
-
#
|
|
|
|
| 24 |
ENV HF_HUB_OFFLINE=1
|
| 25 |
ENV TRANSFORMERS_OFFLINE=1
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
EXPOSE 7860
|
| 28 |
|
| 29 |
CMD ["uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 7 |
RUN pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
COPY server/ server/
|
| 11 |
COPY config.yaml .
|
| 12 |
COPY data/ground_truth/ data/ground_truth/
|
|
|
|
| 17 |
RUN useradd -m -u 1000 user && chown -R user /app
|
| 18 |
USER user
|
| 19 |
|
| 20 |
+
# Cache must be under /app so user 1000 can read it at runtime
|
| 21 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 22 |
ENV HF_HUB_OFFLINE=1
|
| 23 |
ENV TRANSFORMERS_OFFLINE=1
|
| 24 |
|
| 25 |
+
# Bake reranker weights into image as user 1000 β written to HF_HOME above
|
| 26 |
+
RUN python -c "from sentence_transformers import CrossEncoder; CrossEncoder('cross-encoder/ms-marco-TinyBERT-L-2-v2')"
|
| 27 |
+
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
CMD ["uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "7860"]
|