dipan004 commited on
Commit
2848bd6
Β·
verified Β·
1 Parent(s): 90ae840

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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 (NEW)
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
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "75"]
 
 
 
 
 
 
 
 
 
 
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"]