eudr_retriever / Dockerfile
mtyrrell's picture
fix to caching on HF spaces for embedding model
ee16869
# # -------- base image --------
# FROM python:3.11-slim
# ENV PYTHONUNBUFFERED=1 \
# OMP_NUM_THREADS=1 \
# TOKENIZERS_PARALLELISM=false
# #GRADIO_MCP_SERVER=True
# # -------- install deps --------
# WORKDIR /app
# COPY requirements.txt .
# RUN pip install --no-cache-dir -r requirements.txt
# # -------- copy source --------
# COPY app ./app
# COPY params.cfg .
# COPY .env* ./
# # Ports:
# # • 7860 → Gradio UI (HF Spaces standard)
# EXPOSE 7860
# CMD ["python", "-m", "app.main"]
FROM python:3.11-slim
WORKDIR /tmp/build
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# --- Create non-root user for the app ---
RUN useradd -m -u 1000 appuser
# Switch to appuser
USER appuser
# --- Set up home/cache for Hugging Face ---
ENV HOME=/home/appuser \
HF_HOME=/home/appuser/.cache/huggingface \
HF_HUB_CACHE=/home/appuser/.cache/huggingface/hub
RUN mkdir -p $HF_HUB_CACHE
WORKDIR /home/appuser
# -------- copy source --------
COPY --chown=appuser:appuser app ./app
COPY --chown=appuser:appuser params.cfg .
COPY --chown=appuser:appuser .env* ./
# Ports:
EXPOSE 7860
# (Optional) Clean up lock files before app starts
ENTRYPOINT ["/bin/bash", "-c", "find $HF_HUB_CACHE -name '*.lock' -delete && python -m app.main"]