File size: 1,309 Bytes
1e57df1
 
 
 
2c41dce
 
1e57df1
 
 
 
2c41dce
 
1e57df1
2c41dce
1e57df1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c41dce
bbf44ca
2c41dce
1e57df1
 
2c41dce
1e57df1
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
# STRATEGY: Start fast WITHOUT Tesseract, install on first OCR request
# Startup: ~2 minutes | First OCR request: +30 seconds (one-time)

FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1 \
    PORT=7860 \
    OCR_ENABLED=true \
    AI_ENABLED=false

WORKDIR /app

# Install only Python packages (fast)
COPY requirements.txt .
RUN pip install --no-cache-dir \
    fastapi==0.104.1 \
    uvicorn[standard]==0.24.0 \
    python-multipart==0.0.6 \
    python-dotenv==1.0.0 \
    Pillow==10.1.0 \
    pytesseract==0.3.10

# Copy app files
COPY app.py .
COPY core/ ./core/
COPY agents/ ./agents/
COPY models/ ./models/
COPY config/ ./config/
COPY sidecar/ ./sidecar/

# Create install script for Tesseract (runs on first OCR request)
RUN echo '#!/bin/bash\n\
if ! command -v tesseract &> /dev/null; then\n\
    echo "Installing Tesseract..."\n\
    apt-get update && apt-get install -y --no-install-recommends tesseract-ocr tesseract-ocr-eng\n\
    rm -rf /var/lib/apt/lists/*\n\
fi' > /app/install_tesseract.sh && chmod +x /app/install_tesseract.sh

# Note: Tesseract NOT installed yet - will be installed on first OCR use
# This makes initial startup much faster

EXPOSE 7860

# No health check for fastest startup
HEALTHCHECK NONE

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]