File size: 1,665 Bytes
0a4529c
 
 
 
ba8a971
0a4529c
 
 
 
8adb9d2
 
 
ba8a971
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a4529c
ba8a971
 
0a4529c
 
 
 
6c8f7a8
 
 
0a4529c
 
 
 
 
a5a1d6e
 
0a4529c
ba8a971
 
4082998
 
 
0a4529c
 
 
 
 
 
ba8a971
 
 
 
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
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies for OpenCV, OCR, and basic utilities
RUN apt-get update && apt-get install -y \
    build-essential \
    libmagic1 \
    file \
    # OpenCV dependencies for Debian 12
    libglx-mesa0 \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    libgomp1 \
    libstdc++6 \
    # OCR dependencies
    tesseract-ocr \
    tesseract-ocr-eng \
    poppler-utils \
    # Additional utilities
    wget \
    curl \
    git \
    # Clean up
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
    pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Create directories with proper permissions
RUN mkdir -p data/uploads data/vector_store data/backups logs && \
    chmod -R 777 data/ logs/

# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
ENV OLLAMA_ENABLED=false
ENV USE_OPENAI=true
ENV LLM_PROVIDER=openai
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONPATH=/app:$PYTHONPATH
ENV OMP_NUM_THREADS=1
ENV PADDLE_PADDLE_NO_WARN=1
ENV PADDLE_NO_WARN=1

# Expose port for HF Spaces
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD python -c "import requests; requests.get('http://localhost:7860/api/health', timeout=5)" || exit 1

# Start application with optimized settings for Hugging Face Spaces
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "120"]