Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -4
Dockerfile
CHANGED
|
@@ -51,17 +51,26 @@ 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
|
| 60 |
-
RUN echo "ποΈ Initializing database..." && \
|
| 61 |
python backend/app/db/db_init.py && \
|
| 62 |
echo "β
Database initialized successfully!"
|
| 63 |
|
| 64 |
# Expose port
|
| 65 |
EXPOSE 7860
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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!"
|
| 63 |
|
| 64 |
# Expose port
|
| 65 |
EXPOSE 7860
|
| 66 |
|
| 67 |
+
# Create startup script that ensures DB exists before running app
|
| 68 |
+
RUN echo '#!/bin/bash\n\
|
| 69 |
+
echo "π Checking database..."\n\
|
| 70 |
+
python backend/app/db/db_init.py\n\
|
| 71 |
+
echo "β
Database ready"\n\
|
| 72 |
+
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"]
|