dipan004 commited on
Commit
1e57df1
·
verified ·
1 Parent(s): 9072a85

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -34
Dockerfile CHANGED
@@ -1,43 +1,47 @@
1
- # Multi-stage build for optimized image size
2
- FROM python:3.11-slim as base
 
 
3
 
4
- # Set environment variables
5
  ENV PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1 \
7
- PIP_NO_CACHE_DIR=1 \
8
- PIP_DISABLE_PIP_VERSION_CHECK=1
9
-
10
- # Install system dependencies
11
- # Tesseract is optional but included for OCR support
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- tesseract-ocr \
14
- tesseract-ocr-eng \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
- # Create app directory
18
  WORKDIR /app
19
 
20
- # Copy requirements first for better caching
21
  COPY requirements.txt .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- # Install Python dependencies
24
- RUN pip install --no-cache-dir -r requirements.txt
25
-
26
- # Copy application code
27
- COPY . .
28
-
29
- # Create non-root user for security
30
- RUN useradd -m -u 1000 appuser && \
31
- chown -R appuser:appuser /app
32
-
33
- USER appuser
34
-
35
- # Expose port
36
  EXPOSE 7860
37
 
38
- # Health check
39
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
40
- CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
41
 
42
- # Run application
43
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # STRATEGY: Start fast WITHOUT Tesseract, install on first OCR request
2
+ # Startup: ~2 minutes | First OCR request: +30 seconds (one-time)
3
+
4
+ FROM python:3.11-slim
5
 
 
6
  ENV PYTHONUNBUFFERED=1 \
7
+ PORT=7860 \
8
+ OCR_ENABLED=true \
9
+ AI_ENABLED=false
10
+
 
 
 
 
 
 
 
 
11
  WORKDIR /app
12
 
13
+ # Install only Python packages (fast)
14
  COPY requirements.txt .
15
+ RUN pip install --no-cache-dir \
16
+ fastapi==0.104.1 \
17
+ uvicorn[standard]==0.24.0 \
18
+ python-multipart==0.0.6 \
19
+ python-dotenv==1.0.0 \
20
+ Pillow==10.1.0 \
21
+ pytesseract==0.3.10
22
+
23
+ # Copy app files
24
+ COPY app.py .
25
+ COPY core/ ./core/
26
+ COPY agents/ ./agents/
27
+ COPY models/ ./models/
28
+ COPY config/ ./config/
29
+ COPY sidecar/ ./sidecar/
30
+
31
+ # Create install script for Tesseract (runs on first OCR request)
32
+ RUN echo '#!/bin/bash\n\
33
+ if ! command -v tesseract &> /dev/null; then\n\
34
+ echo "Installing Tesseract..."\n\
35
+ apt-get update && apt-get install -y --no-install-recommends tesseract-ocr tesseract-ocr-eng\n\
36
+ rm -rf /var/lib/apt/lists/*\n\
37
+ fi' > /app/install_tesseract.sh && chmod +x /app/install_tesseract.sh
38
+
39
+ # Note: Tesseract NOT installed yet - will be installed on first OCR use
40
+ # This makes initial startup much faster
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  EXPOSE 7860
43
 
44
+ # No health check for fastest startup
45
+ HEALTHCHECK NONE
 
46
 
47
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]