dipan004 commited on
Commit
6f5f8ce
Β·
verified Β·
1 Parent(s): ff1fc5f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +57 -46
Dockerfile CHANGED
@@ -25,36 +25,46 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
25
  python3-dev \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
- # Verify Tesseract installation
29
  RUN tesseract --version
30
 
31
  # ===============================
32
- # Copy requirements and upgrade pip
33
- # ===============================
34
- COPY requirements.txt .
35
-
36
- RUN pip install --no-cache-dir --upgrade pip setuptools wheel cython
37
-
38
- # ===============================
39
- # Install NumPy first (prebuilt wheel)
40
- # ===============================
41
- RUN pip install --no-cache-dir numpy==1.24.4
42
-
43
- # ===============================
44
- # Install Pandas from prebuilt wheel (avoid --no-binary)
45
- # ===============================
46
- RUN pip install --no-cache-dir pandas==2.0.3 --only-binary=:all:
47
-
48
- # ===============================
49
- # Install remaining dependencies
50
- # ===============================
51
- RUN pip install --no-cache-dir -r requirements.txt
52
-
53
- # ===============================
54
- # Optional: Gemini SDK, EasyOCR
55
- # ===============================
56
- RUN pip install --no-cache-dir --upgrade google-generativeai google-ai-generativelanguage
57
- RUN pip install --no-cache-dir easyocr opencv-python-headless Pillow pytesseract
 
 
 
 
 
 
 
 
 
 
58
 
59
  # ===============================
60
  # Copy application code
@@ -62,35 +72,35 @@ RUN pip install --no-cache-dir easyocr opencv-python-headless Pillow pytesseract
62
  COPY . .
63
 
64
  # ===============================
65
- # Create necessary directories
66
  # ===============================
67
- RUN mkdir -p /app/data/logs /app/data/docs /app/backend/app/db && chmod -R 777 /app/data
 
68
 
69
  # ===============================
70
- # Create __init__.py files
71
  # ===============================
72
  RUN touch backend/__init__.py \
73
- && touch backend/feature_builder/__init__.py \
74
- && touch backend/app/__init__.py \
75
- && touch backend/app/api/__init__.py \
76
- && touch backend/app/agent/__init__.py \
77
- && touch backend/app/wrappers/__init__.py \
78
- && touch backend/app/db/__init__.py \
79
- && touch backend/ingest/__init__.py
80
 
81
  # ===============================
82
- # Verify agent files exist
83
  # ===============================
84
  RUN test -f backend/app/agent/agent_orchestrator.py || \
85
- (echo "ERROR: agent_orchestrator.py not found! Add it before building." && exit 1)
86
 
87
  # ===============================
88
- # Initialize database
89
  # ===============================
90
- COPY backend/app/db/db_init.py backend/app/db/db_init.py
91
- RUN echo "πŸ—„οΈ Initializing database during build..." && \
92
  python backend/app/db/db_init.py && \
93
- echo "βœ… Database initialized successfully!"
94
 
95
  # ===============================
96
  # Expose port
@@ -101,10 +111,11 @@ EXPOSE 7860
101
  # Startup script
102
  # ===============================
103
  RUN echo '#!/bin/bash\n\
104
- echo "πŸ” Checking database..."\n\
 
105
  python backend/app/db/db_init.py\n\
106
- echo "βœ… Database ready"\n\
107
- echo "πŸš€ Starting application..."\n\
108
  exec uvicorn app:app --host 0.0.0.0 --port 7860 --timeout-keep-alive 75\n\
109
  ' > /app/start.sh && chmod +x /app/start.sh
110
 
 
25
  python3-dev \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
+ # Verify Tesseract
29
  RUN tesseract --version
30
 
31
  # ===============================
32
+ # Python tooling
33
+ # ===============================
34
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
35
+
36
+ # ===============================
37
+ # πŸ”’ CRITICAL: single dependency layer
38
+ # ===============================
39
+ RUN pip install --no-cache-dir \
40
+ numpy==1.24.4 \
41
+ pandas==2.0.3 \
42
+ fastapi==0.104.1 \
43
+ uvicorn[standard]==0.24.0 \
44
+ pydantic==2.5.0 \
45
+ scikit-learn==1.6.1 \
46
+ lightgbm==4.1.0 \
47
+ joblib==1.3.2 \
48
+ python-dateutil==2.8.2 \
49
+ filelock==3.13.1 \
50
+ python-multipart==0.0.6 \
51
+ httpx==0.25.2 \
52
+ redis==5.0.1 \
53
+ rq==1.15.1 \
54
+ pdfplumber==0.10.3 \
55
+ PyMuPDF==1.23.8 \
56
+ pytesseract==0.3.10 \
57
+ Pillow==10.1.0 \
58
+ python-magic==0.4.27 \
59
+ requests==2.31.0 \
60
+ python-dotenv==1.0.0 \
61
+ psycopg2-binary==2.9.7 \
62
+ SQLAlchemy==2.0.20 \
63
+ alembic==1.11.1 \
64
+ google-generativeai \
65
+ google-ai-generativelanguage \
66
+ easyocr \
67
+ opencv-python-headless
68
 
69
  # ===============================
70
  # Copy application code
 
72
  COPY . .
73
 
74
  # ===============================
75
+ # Runtime directories
76
  # ===============================
77
+ RUN mkdir -p /app/data/logs /app/data/docs /app/backend/app/db \
78
+ && chmod -R 777 /app/data
79
 
80
  # ===============================
81
+ # Python package structure
82
  # ===============================
83
  RUN touch backend/__init__.py \
84
+ backend/feature_builder/__init__.py \
85
+ backend/app/__init__.py \
86
+ backend/app/api/__init__.py \
87
+ backend/app/agent/__init__.py \
88
+ backend/app/wrappers/__init__.py \
89
+ backend/app/db/__init__.py \
90
+ backend/ingest/__init__.py
91
 
92
  # ===============================
93
+ # Verify agent file exists
94
  # ===============================
95
  RUN test -f backend/app/agent/agent_orchestrator.py || \
96
+ (echo "❌ ERROR: agent_orchestrator.py missing" && exit 1)
97
 
98
  # ===============================
99
+ # Initialize database at build time
100
  # ===============================
101
+ RUN echo "πŸ—„οΈ Initializing database..." && \
 
102
  python backend/app/db/db_init.py && \
103
+ echo "βœ… Database ready"
104
 
105
  # ===============================
106
  # Expose port
 
111
  # Startup script
112
  # ===============================
113
  RUN echo '#!/bin/bash\n\
114
+ set -e\n\
115
+ echo \"πŸ” Checking database...\"\n\
116
  python backend/app/db/db_init.py\n\
117
+ echo \"βœ… Database ready\"\n\
118
+ echo \"πŸš€ Starting application...\"\n\
119
  exec uvicorn app:app --host 0.0.0.0 --port 7860 --timeout-keep-alive 75\n\
120
  ' > /app/start.sh && chmod +x /app/start.sh
121