File size: 2,653 Bytes
32a3bbb
 
 
 
 
d542234
5630f6b
32a3bbb
 
 
5630f6b
 
32a3bbb
 
 
 
 
 
d542234
32a3bbb
 
 
 
 
 
 
 
5630f6b
 
 
 
 
32a3bbb
 
 
25eb4cf
32a3bbb
 
 
 
d542234
5630f6b
32a3bbb
 
 
d542234
5630f6b
32a3bbb
 
 
 
 
 
 
 
d542234
5630f6b
32a3bbb
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# ============================================================
# 🧩 Enterprise Knowledge Assistant — Hugging Face Space Dockerfile
# ============================================================

# ✅ Use Python 3.10 — stable for FAISS, PyMuPDF, Transformers
FROM python:3.10-slim

# ------------------------------------------------------------
# 1️⃣ Set working directory
# ------------------------------------------------------------
WORKDIR /app

# ------------------------------------------------------------
# 2️⃣ Environment variables
# ------------------------------------------------------------
# - PYTHONUNBUFFERED: ensures logs show up live
# - HF_*: route all Hugging Face model cache to writable folder (/app/hf_cache)
# - STREAMLIT server flags: make Streamlit work inside HF Space
ENV PYTHONUNBUFFERED=1 \
    HF_HOME=/app/hf_cache \
    TRANSFORMERS_CACHE=/app/hf_cache \
    HF_DATASETS_CACHE=/app/hf_cache \
    HF_MODULES_CACHE=/app/hf_cache

# ------------------------------------------------------------
# 3️⃣ Install system dependencies
# ------------------------------------------------------------
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    && rm -rf /var/lib/apt/lists/*

# ------------------------------------------------------------
# 4️⃣ Copy requirements first for Docker layer caching
# ------------------------------------------------------------
COPY requirements.txt .

# ------------------------------------------------------------
# 5️⃣ Install Python dependencies
# ------------------------------------------------------------
RUN pip install --no-cache-dir -r requirements.txt

# ------------------------------------------------------------
# 6️⃣ Copy the entire app
# ------------------------------------------------------------
COPY . .

# ------------------------------------------------------------
# 7️⃣ Create cache folder with proper permissions
# ------------------------------------------------------------
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache

# ------------------------------------------------------------
# 8️⃣ Expose Streamlit’s default port
# ------------------------------------------------------------
EXPOSE 8501

# ------------------------------------------------------------
# 9️⃣ Start Streamlit with flags to fix upload (403) and XSRF issues
# ------------------------------------------------------------
CMD ["streamlit", "run", "src/streamlit_app.py", \
    "--server.port=8501", \
    "--server.address=0.0.0.0", \
    "--server.enableXsrfProtection=false", \
    "--server.enableCORS=true"]