Upload 2 files
Browse files- Dockerfile +56 -0
- requirements.txt +10 -0
Dockerfile
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---------- Stage 1: build dependencies ----------
|
| 2 |
+
FROM python:3.11-slim AS builder
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# System deps for PyMuPDF and chromadb native builds
|
| 7 |
+
RUN apt-get update && \
|
| 8 |
+
apt-get install -y --no-install-recommends \
|
| 9 |
+
build-essential \
|
| 10 |
+
libffi-dev \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
COPY requirements.txt .
|
| 14 |
+
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# ---------- Stage 2: runtime image ----------
|
| 17 |
+
FROM python:3.11-slim
|
| 18 |
+
|
| 19 |
+
# HF Spaces requires a non-root user with uid 1000
|
| 20 |
+
RUN useradd -m -u 1000 user
|
| 21 |
+
WORKDIR /home/user/app
|
| 22 |
+
|
| 23 |
+
# Minimal runtime libraries needed by PyMuPDF / Pillow
|
| 24 |
+
RUN apt-get update && \
|
| 25 |
+
apt-get install -y --no-install-recommends \
|
| 26 |
+
libglib2.0-0 \
|
| 27 |
+
libsm6 \
|
| 28 |
+
libxext6 \
|
| 29 |
+
libxrender1 \
|
| 30 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 31 |
+
|
| 32 |
+
# Copy installed Python packages from the builder stage
|
| 33 |
+
COPY --from=builder /install /usr/local
|
| 34 |
+
|
| 35 |
+
# Copy application source and set ownership to non-root user
|
| 36 |
+
COPY --chown=user:user . .
|
| 37 |
+
|
| 38 |
+
# Writable cache directories for the non-root user
|
| 39 |
+
RUN mkdir -p /home/user/app/.cache && chown -R user:user /home/user/app/.cache
|
| 40 |
+
|
| 41 |
+
USER user
|
| 42 |
+
|
| 43 |
+
ENV PYTHONUNBUFFERED=1
|
| 44 |
+
ENV HOME=/home/user
|
| 45 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 46 |
+
|
| 47 |
+
# HF Spaces expects port 7860
|
| 48 |
+
ENV STREAMLIT_SERVER_PORT=7860
|
| 49 |
+
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 50 |
+
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
| 51 |
+
|
| 52 |
+
EXPOSE 7860
|
| 53 |
+
|
| 54 |
+
HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/_stcore/health')"
|
| 55 |
+
|
| 56 |
+
ENTRYPOINT ["streamlit", "run", "app.py"]
|
requirements.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit>=1.40.0
|
| 2 |
+
langgraph>=0.2.0
|
| 3 |
+
langchain-core>=0.3.0
|
| 4 |
+
google-genai>=1.0.0
|
| 5 |
+
openai>=1.50.0
|
| 6 |
+
chromadb>=0.5.0
|
| 7 |
+
sentence-transformers>=3.0.0
|
| 8 |
+
Pillow>=10.0.0
|
| 9 |
+
python-dotenv>=1.0.0
|
| 10 |
+
pymupdf>=1.24.0
|