Skip to content

Commit 106be85

Browse files
committed
Update Dockerfile and requirements for Hypercorn support; add startup script
1 parent 5c7d646 commit 106be85

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,22 @@ RUN apt-get update && \
1919
COPY 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
2527
COPY . .
2628

29+
# Make start script executable
30+
RUN chmod +x start.sh
31+
2732
# Expose port
2833
EXPOSE 8000
2934

3035
# Health check
3136
HEALTHCHECK --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"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ beautifulsoup4>=4.9.0
1717
fastapi>=0.110.0,<1.0.0
1818
uvicorn[standard]>=0.24.0
1919
python-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

start.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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

0 commit comments

Comments
 (0)