Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +27 -14
Dockerfile
CHANGED
|
@@ -14,20 +14,38 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 14 |
libxext6 \
|
| 15 |
libxrender-dev \
|
| 16 |
libgl1 \
|
|
|
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
# Verify Tesseract installation
|
| 20 |
RUN tesseract --version
|
| 21 |
|
| 22 |
-
#
|
|
|
|
|
|
|
|
|
|
| 23 |
COPY requirements.txt .
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Upgrade Gemini SDK for v1 API
|
| 28 |
RUN pip install --no-cache-dir --upgrade google-generativeai google-ai-generativelanguage
|
| 29 |
|
| 30 |
-
# Install EasyOCR
|
| 31 |
RUN pip install --no-cache-dir easyocr opencv-python-headless Pillow pytesseract
|
| 32 |
|
| 33 |
# Copy application code
|
|
@@ -36,7 +54,7 @@ COPY . .
|
|
| 36 |
# Create necessary directories
|
| 37 |
RUN mkdir -p /app/data/logs /app/data/docs /app/backend/app/db && chmod -R 777 /app/data
|
| 38 |
|
| 39 |
-
# Create __init__.py files
|
| 40 |
RUN touch backend/__init__.py \
|
| 41 |
&& touch backend/feature_builder/__init__.py \
|
| 42 |
&& touch backend/app/__init__.py \
|
|
@@ -46,17 +64,12 @@ RUN touch backend/__init__.py \
|
|
| 46 |
&& touch backend/app/db/__init__.py \
|
| 47 |
&& touch backend/ingest/__init__.py
|
| 48 |
|
| 49 |
-
# Verify agent files exist
|
| 50 |
RUN test -f backend/app/agent/agent_orchestrator.py || \
|
| 51 |
(echo "ERROR: agent_orchestrator.py not found! Add it before building." && exit 1)
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
# INITIALIZE DATABASE
|
| 55 |
-
# ============================================
|
| 56 |
-
# Copy db_init.py to the correct location
|
| 57 |
COPY backend/app/db/db_init.py backend/app/db/db_init.py
|
| 58 |
-
|
| 59 |
-
# Run database initialization during build
|
| 60 |
RUN echo "🗄️ Initializing database during build..." && \
|
| 61 |
python backend/app/db/db_init.py && \
|
| 62 |
echo "✅ Database initialized successfully!"
|
|
@@ -64,7 +77,7 @@ RUN echo "🗄️ Initializing database during build..." && \
|
|
| 64 |
# Expose port
|
| 65 |
EXPOSE 7860
|
| 66 |
|
| 67 |
-
#
|
| 68 |
RUN echo '#!/bin/bash\n\
|
| 69 |
echo "🔍 Checking database..."\n\
|
| 70 |
python backend/app/db/db_init.py\n\
|
|
@@ -73,4 +86,4 @@ echo "🚀 Starting application..."\n\
|
|
| 73 |
exec uvicorn app:app --host 0.0.0.0 --port 7860 --timeout-keep-alive 75\n\
|
| 74 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 75 |
|
| 76 |
-
CMD ["/app/start.sh"]
|
|
|
|
| 14 |
libxext6 \
|
| 15 |
libxrender-dev \
|
| 16 |
libgl1 \
|
| 17 |
+
build-essential \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
# Verify Tesseract installation
|
| 21 |
RUN tesseract --version
|
| 22 |
|
| 23 |
+
# --------------------------------------------
|
| 24 |
+
# 🔧 FIX: NumPy–Pandas binary compatibility
|
| 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 |
+
# Install NumPy FIRST (stable ABI)
|
| 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 WITHOUT touching numpy/pandas
|
| 39 |
+
RUN pip install --no-cache-dir -r requirements.txt --no-deps
|
| 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
|
|
|
|
| 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 |
+
# Create __init__.py files
|
| 58 |
RUN touch backend/__init__.py \
|
| 59 |
&& touch backend/feature_builder/__init__.py \
|
| 60 |
&& touch backend/app/__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 |
+
# Initialize database
|
|
|
|
|
|
|
|
|
|
| 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!"
|
|
|
|
| 77 |
# Expose port
|
| 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\
|
|
|
|
| 86 |
exec uvicorn app:app --host 0.0.0.0 --port 7860 --timeout-keep-alive 75\n\
|
| 87 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 88 |
|
| 89 |
+
CMD ["/app/start.sh"]
|