Skip to content

Commit 699efec

Browse files
committed
feat: add uvicorn fallback for server startup and install runpod into existing virtual environment
1 parent 639bf8c commit 699efec

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Dockerfile.wrapper

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Use the existing working Kokoro FastAPI image as base
22
FROM ghcr.io/remsky/kokoro-fastapi-gpu:latest
33

4-
# Switch to root to install additional packages
5-
USER root
6-
7-
# Install runpod and any additional dependencies
8-
RUN pip install runpod>=1.0.0
9-
104
# Copy the serverless handler
115
COPY handler-wrapper.py /app/handler.py
126

7+
# Switch to root to install runpod in the existing virtual environment
8+
USER root
9+
RUN /app/.venv/bin/pip install runpod>=1.0.0
10+
1311
# Switch back to appuser
1412
USER appuser
1513

handler-wrapper.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,20 @@ def start_fastapi():
2626

2727
logger.info("Starting internal FastAPI server...")
2828

29-
# Start the FastAPI server using the existing entrypoint
30-
fastapi_process = subprocess.Popen([
31-
"/app/entrypoint.sh"
32-
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
29+
# Start the FastAPI server using the existing startup method
30+
# Try entrypoint.sh first, then fallback to direct uvicorn
31+
try:
32+
fastapi_process = subprocess.Popen([
33+
"/app/entrypoint.sh"
34+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
35+
except FileNotFoundError:
36+
# Fallback to direct uvicorn start if entrypoint.sh doesn't exist
37+
fastapi_process = subprocess.Popen([
38+
"/app/.venv/bin/python", "-m", "uvicorn",
39+
"api.src.main:app",
40+
"--host", "0.0.0.0",
41+
"--port", "8880"
42+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd="/app")
3343

3444
# Wait for the server to be ready
3545
max_wait = 120 # 2 minutes max wait

0 commit comments

Comments
 (0)