Files
copilotkit__copilotkit/examples/integrations/langgraph-python/docker-route-override.ts
Jordan Ritter 8c26e30fba Dockerize all 12 starter examples for Railway deployment
Each starter gets a Dockerfile, entrypoint.sh, and .dockerignore.
Docker-specific adaptations only — original code untouched:
- HOSTNAME=0.0.0.0 for Next.js standalone
- PORT override for Python agents (Railway sets PORT=3000)
- uv sync --frozen for exact dep resolution from lockfiles
- serve.py + docker-route-override.ts for LangGraph starters
  (langgraph-cli dev needs Docker-in-Docker, unavailable on Railway)
- next.config.ts: ignoreBuildErrors for HttpAgent type mismatch
- Mastra: workingMemory scope: thread for standalone deploy
- CVE fix: patch package.json to next@15.3.8 at deploy time
2026-04-07 14:08:28 -07:00

32 lines
911 B
TypeScript

/**
* Docker-specific route override.
* In Docker, the agent is served via AG-UI (not LangGraph Platform)
* because langgraph-cli dev requires Docker-in-Docker.
* The original route.ts (using LangGraphAgent) is preserved unchanged.
*/
import {
CopilotRuntime,
ExperimentalEmptyAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
import { HttpAgent } from "@ag-ui/client";
import { NextRequest } from "next/server";
const agentUrl = process.env.AGENT_URL || "http://localhost:8123";
const defaultAgent = new HttpAgent({
url: `${agentUrl}/`,
});
export const POST = async (req: NextRequest) => {
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
endpoint: "/api/copilotkit",
serviceAdapter: new ExperimentalEmptyAdapter(),
runtime: new CopilotRuntime({
agents: { default: defaultAgent },
}),
});
return handleRequest(req);
};