lexrag / Dockerfile
RV302001's picture
Initial commit: LexRAG hybrid legal RAG
cc0207f
Raw
History Blame Contribute Delete
836 Bytes
FROM python:3.11-slim
# psycopg2-binary needs no build deps; keep image lean.
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/home/appuser/.cache/huggingface \
SENTENCE_TRANSFORMERS_HOME=/home/appuser/.cache/huggingface
# HF Spaces runs as uid 1000.
RUN useradd -m -u 1000 appuser
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download the bge model at build time -> fast cold start, writable cache.
RUN mkdir -p $HF_HOME && \
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-small-en-v1.5')" && \
chown -R appuser:appuser /home/appuser/.cache
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]