File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed
Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -19,17 +19,22 @@ RUN apt-get update && \
1919COPY requirements.txt .
2020
2121# Install Python dependencies
22- RUN pip install --no-cache-dir -r requirements.txt
22+ RUN pip install --no-cache-dir --upgrade pip && \
23+ pip install --no-cache-dir -r requirements.txt && \
24+ pip install --no-cache-dir hypercorn>=0.18.0
2325
2426# Copy application code
2527COPY . .
2628
29+ # Make start script executable
30+ RUN chmod +x start.sh
31+
2732# Expose port
2833EXPOSE 8000
2934
3035# Health check
3136HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
3237 CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1
3338
34- # Run the application with Hypercorn
35- CMD ["sh" , "-c" , "hypercorn server:app --bind 0.0.0.0:${PORT} " ]
39+ # Run the application with Hypercorn (fallback to uvicorn)
40+ CMD ["./start.sh " ]
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ beautifulsoup4>=4.9.0
1717fastapi >= 0.110.0 ,< 1.0.0
1818uvicorn [standard ]>= 0.24.0
1919python-dotenv >= 1.0.0
20-
20+ hypercorn >= 0.18.0
2121# Optional: Development dependencies
2222# Install with: pip install -e ".[dev]"
2323# pytest>=7.0.0
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # Startup script for the Meta AI API server
3+
4+ # Use PORT from environment or default to 8000
5+ PORT=${PORT:- 8000}
6+ HOST=${HOST:- 0.0.0.0}
7+
8+ echo " Starting Meta AI API Server..."
9+ echo " Host: $HOST "
10+ echo " Port: $PORT "
11+
12+ # Try hypercorn first (preferred for Python 3.13)
13+ if command -v hypercorn > /dev/null 2>&1 ; then
14+ echo " Using Hypercorn ASGI server"
15+ exec hypercorn server:app --bind " $HOST :$PORT "
16+ else
17+ echo " Hypercorn not found, using Uvicorn"
18+ exec uvicorn server:app --host " $HOST " --port " $PORT "
19+ fi
You can’t perform that action at this time.
0 commit comments