Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +21 -14
Dockerfile
CHANGED
|
@@ -2,7 +2,9 @@ FROM python:3.10-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
# Install system dependencies + OCR libraries
|
|
|
|
| 6 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
sqlite3 \
|
| 8 |
ca-certificates \
|
|
@@ -21,40 +23,39 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 21 |
RUN tesseract --version
|
| 22 |
|
| 23 |
# --------------------------------------------
|
| 24 |
-
#
|
| 25 |
# --------------------------------------------
|
| 26 |
-
|
| 27 |
COPY requirements.txt .
|
| 28 |
|
| 29 |
# Upgrade build tools
|
| 30 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel cython
|
| 31 |
|
| 32 |
-
#
|
| 33 |
RUN pip install --no-cache-dir numpy==1.24.4
|
| 34 |
-
|
| 35 |
-
# Force pandas to compile against installed NumPy
|
| 36 |
RUN pip install --no-cache-dir --no-binary=pandas pandas==2.0.3
|
| 37 |
|
| 38 |
-
# Install remaining dependencies
|
| 39 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 40 |
|
| 41 |
-
# --------------------------------------------
|
| 42 |
-
# Keep everything else exactly the same
|
| 43 |
-
# --------------------------------------------
|
| 44 |
-
|
| 45 |
# Upgrade Gemini SDK for v1 API
|
| 46 |
RUN pip install --no-cache-dir --upgrade google-generativeai google-ai-generativelanguage
|
| 47 |
|
| 48 |
# Install EasyOCR + dependencies
|
| 49 |
RUN pip install --no-cache-dir easyocr opencv-python-headless Pillow pytesseract
|
| 50 |
|
|
|
|
| 51 |
# Copy application code
|
|
|
|
| 52 |
COPY . .
|
| 53 |
|
|
|
|
| 54 |
# Create necessary directories
|
|
|
|
| 55 |
RUN mkdir -p /app/data/logs /app/data/docs /app/backend/app/db && chmod -R 777 /app/data
|
| 56 |
|
| 57 |
-
#
|
|
|
|
|
|
|
| 58 |
RUN touch backend/__init__.py \
|
| 59 |
&& touch backend/feature_builder/__init__.py \
|
| 60 |
&& touch backend/app/__init__.py \
|
|
@@ -64,20 +65,26 @@ RUN touch backend/__init__.py \
|
|
| 64 |
&& touch backend/app/db/__init__.py \
|
| 65 |
&& touch backend/ingest/__init__.py
|
| 66 |
|
| 67 |
-
# Verify agent files exist
|
| 68 |
RUN test -f backend/app/agent/agent_orchestrator.py || \
|
| 69 |
(echo "ERROR: agent_orchestrator.py not found! Add it before building." && exit 1)
|
| 70 |
|
| 71 |
-
#
|
|
|
|
|
|
|
| 72 |
COPY backend/app/db/db_init.py backend/app/db/db_init.py
|
| 73 |
RUN echo "🗄️ Initializing database during build..." && \
|
| 74 |
python backend/app/db/db_init.py && \
|
| 75 |
echo "✅ Database initialized successfully!"
|
| 76 |
|
| 77 |
-
#
|
|
|
|
|
|
|
| 78 |
EXPOSE 7860
|
| 79 |
|
|
|
|
| 80 |
# Startup script
|
|
|
|
| 81 |
RUN echo '#!/bin/bash\n\
|
| 82 |
echo "🔍 Checking database..."\n\
|
| 83 |
python backend/app/db/db_init.py\n\
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# --------------------------------------------
|
| 6 |
# Install system dependencies + OCR libraries
|
| 7 |
+
# --------------------------------------------
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
sqlite3 \
|
| 10 |
ca-certificates \
|
|
|
|
| 23 |
RUN tesseract --version
|
| 24 |
|
| 25 |
# --------------------------------------------
|
| 26 |
+
# Copy requirements and prepare Python environment
|
| 27 |
# --------------------------------------------
|
|
|
|
| 28 |
COPY requirements.txt .
|
| 29 |
|
| 30 |
# Upgrade build tools
|
| 31 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel cython
|
| 32 |
|
| 33 |
+
# 🔧 FIX: NumPy–Pandas binary compatibility
|
| 34 |
RUN pip install --no-cache-dir numpy==1.24.4
|
|
|
|
|
|
|
| 35 |
RUN pip install --no-cache-dir --no-binary=pandas pandas==2.0.3
|
| 36 |
|
| 37 |
+
# Install remaining dependencies from requirements.txt
|
| 38 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Upgrade Gemini SDK for v1 API
|
| 41 |
RUN pip install --no-cache-dir --upgrade google-generativeai google-ai-generativelanguage
|
| 42 |
|
| 43 |
# Install EasyOCR + dependencies
|
| 44 |
RUN pip install --no-cache-dir easyocr opencv-python-headless Pillow pytesseract
|
| 45 |
|
| 46 |
+
# --------------------------------------------
|
| 47 |
# Copy application code
|
| 48 |
+
# --------------------------------------------
|
| 49 |
COPY . .
|
| 50 |
|
| 51 |
+
# --------------------------------------------
|
| 52 |
# Create necessary directories
|
| 53 |
+
# --------------------------------------------
|
| 54 |
RUN mkdir -p /app/data/logs /app/data/docs /app/backend/app/db && chmod -R 777 /app/data
|
| 55 |
|
| 56 |
+
# --------------------------------------------
|
| 57 |
+
# Create __init__.py files for all packages
|
| 58 |
+
# --------------------------------------------
|
| 59 |
RUN touch backend/__init__.py \
|
| 60 |
&& touch backend/feature_builder/__init__.py \
|
| 61 |
&& touch backend/app/__init__.py \
|
|
|
|
| 65 |
&& touch backend/app/db/__init__.py \
|
| 66 |
&& touch backend/ingest/__init__.py
|
| 67 |
|
| 68 |
+
# Verify agent files exist (fail build if missing)
|
| 69 |
RUN test -f backend/app/agent/agent_orchestrator.py || \
|
| 70 |
(echo "ERROR: agent_orchestrator.py not found! Add it before building." && exit 1)
|
| 71 |
|
| 72 |
+
# --------------------------------------------
|
| 73 |
+
# Initialize database during build
|
| 74 |
+
# --------------------------------------------
|
| 75 |
COPY backend/app/db/db_init.py backend/app/db/db_init.py
|
| 76 |
RUN echo "🗄️ Initializing database during build..." && \
|
| 77 |
python backend/app/db/db_init.py && \
|
| 78 |
echo "✅ Database initialized successfully!"
|
| 79 |
|
| 80 |
+
# --------------------------------------------
|
| 81 |
+
# Expose application port
|
| 82 |
+
# --------------------------------------------
|
| 83 |
EXPOSE 7860
|
| 84 |
|
| 85 |
+
# --------------------------------------------
|
| 86 |
# Startup script
|
| 87 |
+
# --------------------------------------------
|
| 88 |
RUN echo '#!/bin/bash\n\
|
| 89 |
echo "🔍 Checking database..."\n\
|
| 90 |
python backend/app/db/db_init.py\n\
|