File size: 1,025 Bytes
ec77441
 
 
 
 
 
 
 
 
 
4c1de34
ec77441
4c1de34
 
 
 
 
e23d7d5
4c1de34
 
 
 
ec77441
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \

    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies in layers to optimize caching and avoid timeouts
COPY requirements.txt .

# 1. Install core dependencies
RUN pip install --no-cache-dir fastapi uvicorn pydantic-settings python-multipart pypdf python-docx

# 2. Install ML/RAG dependencies (Large)
RUN pip install --no-cache-dir langchain langchain-community langchain-huggingface langchain-text-splitters sentence-transformers chromadb huggingface-hub

# 3. Install Torch and Transformers (Very Large)
RUN pip install --no-cache-dir torch transformers accelerate bitsandbytes

# Copy application code
COPY . .

# Create user with UID 1000 (standard for HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose the standard HF port
EXPOSE 7860

CMD ["python", "main.py"]