feat: add unified development environment with nginx proxy

Add a root-level Makefile to manage frontend, backend, and nginx services:
- `make check` validates required dependencies (Node.js 22+, pnpm, uv, nginx)
- `make install` installs all project dependencies
- `make dev` starts all services with unified port 2026
- `make stop` and `make clean` for cleanup

Update nginx configuration:
- Change port from 8000 to 2026
- Add frontend upstream and routing (port 3000)
- Add /api/langgraph/* routing with path rewriting to LangGraph server
- Keep other /api/* routes to Gateway API
- Route non-API requests to frontend

Update frontend configuration:
- Use relative URLs through nginx proxy by default
- Support environment variables for direct backend access
- Construct full URL for LangGraph SDK compatibility

Clean up backend Makefile by removing nginx and serve targets.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hetao
2026-01-22 11:57:47 +08:00
parent 50c25f5c4d
commit 2fac72601e
8 changed files with 376 additions and 69 deletions

View File

@@ -7,33 +7,6 @@ dev:
gateway:
uv run uvicorn src.gateway.app:app --host 0.0.0.0 --port 8001
nginx:
@echo "Stopping existing nginx if any..."
@-nginx -c $(PWD)/../nginx.conf -p $(PWD)/.. -s quit 2>/dev/null || true
@sleep 1
@-pkill -9 nginx 2>/dev/null || true
@sleep 1
@echo "Starting nginx..."
@cleanup() { kill 0 2>/dev/null; exit 0; }; \
trap cleanup EXIT INT TERM; \
nginx -g 'daemon off;' -c $(PWD)/../nginx.conf -p $(PWD)/..
serve:
@echo "Stopping existing services if any..."
@-pkill -f "langgraph dev" 2>/dev/null || true
@-pkill -f "uvicorn src.gateway.app:app" 2>/dev/null || true
@-nginx -c $(PWD)/../nginx.conf -p $(PWD)/.. -s quit 2>/dev/null || true
@sleep 1
@-pkill -9 nginx 2>/dev/null || true
@sleep 1
@echo "Starting services..."
@cleanup() { kill 0 2>/dev/null; sleep 0.5; kill -9 0 2>/dev/null; exit 0; }; \
trap cleanup INT TERM; \
uv run langgraph dev --no-browser --allow-blocking --no-reload & \
sleep 3 && uv run uvicorn src.gateway.app:app --host 0.0.0.0 --port 8001 & \
sleep 1 && nginx -g 'daemon off;' -c $(PWD)/../nginx.conf -p $(PWD)/.. & \
wait
lint:
uvx ruff check .