Bundle FastAPI backend into Next.js Docker container
The Next.js app was proxying /api/* to the old Flask/FastAPI server at legal-ai.nautilus.marcusgroup.org. When that server went down, the Next.js app's API calls failed with 503. Now both services run in the same container: - FastAPI (uvicorn) on :8000 — the API backend - Next.js (node) on :3000 — proxies /api/* to localhost:8000 Changes: - Dockerfile: multi-stage build with Python 3.12 + Node.js - next.config.ts: default proxy target is now 127.0.0.1:8000 - start.sh: launches uvicorn in background + node in foreground - pyproject.toml: add fastapi + uvicorn as explicit deps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
start.sh
Executable file
13
start.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Start FastAPI backend + Next.js frontend in the same container.
|
||||
# Uvicorn runs in the background; Node.js runs in the foreground
|
||||
# so that Docker gets its exit signal from the primary process.
|
||||
|
||||
set -e
|
||||
|
||||
echo "Starting FastAPI backend on :8000 ..."
|
||||
uvicorn web.app:app --host 127.0.0.1 --port 8000 --workers 1 &
|
||||
UVICORN_PID=$!
|
||||
|
||||
echo "Starting Next.js frontend on :3000 ..."
|
||||
exec node server.js
|
||||
Reference in New Issue
Block a user