File size: 1,258 Bytes
19dfd32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ☁️ Dockerfile for Hugging Face Spaces — Cloud-Only (Lightweight)
# Image size: ~500MB (no Ollama, no local models)
# All LLM inference is handled by Groq API and HF Inference API via USE_HF_CLOUD=1
FROM python:3.11-slim

# Prevent Python from writing pyc files and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Cloud mode: all LLM calls go to Groq / HF Inference — no local Ollama needed
ENV USE_HF_CLOUD=1

# Install system dependencies (Tesseract for OCR fallback only)
RUN apt-get update && apt-get install -y \
    curl \
    zstd \
    tesseract-ocr \
    libtesseract-dev \
    gcc \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir llama-index-llms-huggingface-api huggingface_hub

# Copy application code
COPY . .

# Hugging Face Spaces requires port 7860
EXPOSE 7860

# Fix line endings and permissions on startup script
RUN sed -i 's/\r$//' start_hf.sh && chmod +x start_hf.sh
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app 2>/dev/null || true
USER appuser

CMD ["./start_hf.sh"]