feat: unified serve.sh with gateway mode support (#1847)
This commit is contained in:
@@ -19,8 +19,6 @@ services:
|
||||
# cluster via the K8s API.
|
||||
# Backend accesses sandboxes directly via host.docker.internal:{NodePort}.
|
||||
provisioner:
|
||||
profiles:
|
||||
- provisioner
|
||||
build:
|
||||
context: ./provisioner
|
||||
dockerfile: Dockerfile
|
||||
@@ -59,20 +57,25 @@ services:
|
||||
|
||||
# ── Reverse Proxy ──────────────────────────────────────────────────────
|
||||
# Routes API traffic to gateway/langgraph and (optionally) provisioner.
|
||||
# Select nginx config via NGINX_CONF:
|
||||
# - nginx.local.conf (default): no provisioner route (local/aio modes)
|
||||
# - nginx.conf: includes provisioner route (provisioner mode)
|
||||
# LANGGRAPH_UPSTREAM and LANGGRAPH_REWRITE control gateway vs standard
|
||||
# routing (processed by envsubst at container start).
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: deer-flow-nginx
|
||||
ports:
|
||||
- "2026:2026"
|
||||
volumes:
|
||||
- ./nginx/${NGINX_CONF:-nginx.conf}:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf.template:ro
|
||||
environment:
|
||||
- LANGGRAPH_UPSTREAM=${LANGGRAPH_UPSTREAM:-langgraph:2024}
|
||||
- LANGGRAPH_REWRITE=${LANGGRAPH_REWRITE:-/}
|
||||
command: >
|
||||
sh -c "envsubst '$$LANGGRAPH_UPSTREAM $$LANGGRAPH_REWRITE'
|
||||
< /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
|
||||
&& nginx -g 'daemon off;'"
|
||||
depends_on:
|
||||
- frontend
|
||||
- gateway
|
||||
- langgraph
|
||||
networks:
|
||||
- deer-flow-dev
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -29,11 +29,17 @@ services:
|
||||
ports:
|
||||
- "${PORT:-2026}:2026"
|
||||
volumes:
|
||||
- ./nginx/${NGINX_CONF:-nginx.conf}:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf.template:ro
|
||||
environment:
|
||||
- LANGGRAPH_UPSTREAM=${LANGGRAPH_UPSTREAM:-langgraph:2024}
|
||||
- LANGGRAPH_REWRITE=${LANGGRAPH_REWRITE:-/}
|
||||
command: >
|
||||
sh -c "envsubst '$$LANGGRAPH_UPSTREAM $$LANGGRAPH_REWRITE'
|
||||
< /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
|
||||
&& nginx -g 'daemon off;'"
|
||||
depends_on:
|
||||
- frontend
|
||||
- gateway
|
||||
- langgraph
|
||||
networks:
|
||||
- deer-flow
|
||||
restart: unless-stopped
|
||||
@@ -68,7 +74,7 @@ services:
|
||||
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:0.7.20}
|
||||
UV_INDEX_URL: ${UV_INDEX_URL:-https://pypi.org/simple}
|
||||
container_name: deer-flow-gateway
|
||||
command: sh -c "cd backend && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 --workers 2"
|
||||
command: sh -c "cd backend && PYTHONPATH=. uv run uvicorn app.gateway.app:app --host 0.0.0.0 --port 8001 --workers ${GATEWAY_WORKERS:-4}"
|
||||
volumes:
|
||||
- ${DEER_FLOW_CONFIG_PATH}:/app/backend/config.yaml:ro
|
||||
- ${DEER_FLOW_EXTENSIONS_CONFIG_PATH}:/app/backend/extensions_config.json:ro
|
||||
@@ -160,13 +166,12 @@ services:
|
||||
|
||||
# ── Sandbox Provisioner (optional, Kubernetes mode) ────────────────────────
|
||||
provisioner:
|
||||
profiles:
|
||||
- provisioner
|
||||
build:
|
||||
context: ./provisioner
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
APT_MIRROR: ${APT_MIRROR:-}
|
||||
PIP_INDEX_URL: ${PIP_INDEX_URL:-}
|
||||
container_name: deer-flow-provisioner
|
||||
volumes:
|
||||
- ~/.kube/config:/root/.kube/config:ro
|
||||
|
||||
+5
-31
@@ -27,7 +27,7 @@ http {
|
||||
}
|
||||
|
||||
upstream langgraph {
|
||||
server langgraph:2024;
|
||||
server ${LANGGRAPH_UPSTREAM};
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
@@ -57,9 +57,11 @@ http {
|
||||
}
|
||||
|
||||
# LangGraph API routes
|
||||
# Rewrites /api/langgraph/* to /* before proxying
|
||||
# In standard mode: /api/langgraph/* → langgraph:2024 (rewrite to /*)
|
||||
# In gateway mode: /api/langgraph/* → gateway:8001 (rewrite to /api/*)
|
||||
# Controlled by LANGGRAPH_UPSTREAM and LANGGRAPH_REWRITE env vars.
|
||||
location /api/langgraph/ {
|
||||
rewrite ^/api/langgraph/(.*) /$1 break;
|
||||
rewrite ^/api/langgraph/(.*) ${LANGGRAPH_REWRITE}$1 break;
|
||||
proxy_pass http://langgraph;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
@@ -84,34 +86,6 @@ http {
|
||||
chunked_transfer_encoding on;
|
||||
}
|
||||
|
||||
# Experimental: Gateway-backed LangGraph-compatible API
|
||||
# Frontend can opt-in via NEXT_PUBLIC_LANGGRAPH_BASE_URL=/api/langgraph-compat
|
||||
location /api/langgraph-compat/ {
|
||||
rewrite ^/api/langgraph-compat/(.*) /api/$1 break;
|
||||
proxy_pass http://gateway;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Headers
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Connection '';
|
||||
|
||||
# SSE/Streaming support
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_set_header X-Accel-Buffering no;
|
||||
|
||||
# Timeouts for long-running requests
|
||||
proxy_connect_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
# Chunked transfer encoding
|
||||
chunked_transfer_encoding on;
|
||||
}
|
||||
|
||||
# Custom API: Models endpoint
|
||||
location /api/models {
|
||||
proxy_pass http://gateway;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
FROM python:3.12-slim-bookworm
|
||||
|
||||
ARG APT_MIRROR
|
||||
ARG PIP_INDEX_URL
|
||||
|
||||
# Optionally override apt mirror for restricted networks (e.g. APT_MIRROR=mirrors.aliyun.com)
|
||||
RUN if [ -n "${APT_MIRROR}" ]; then \
|
||||
@@ -15,6 +16,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir \
|
||||
${PIP_INDEX_URL:+--index-url "$PIP_INDEX_URL"} \
|
||||
fastapi \
|
||||
"uvicorn[standard]" \
|
||||
kubernetes
|
||||
|
||||
Reference in New Issue
Block a user