Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Bind to 0.0.0.0 in prod image

Chirag Jaina4c932074ecf
diff --git a/Dockerfile b/Dockerfile
index f7a541b4d..e1433ebe9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,8 +11,10 @@
FROM node:24-slim AS runner
WORKDIR /app
-ENV NODE_ENV=production
-ENV STANDALONE=false
+# HOST=0.0.0.0 so Kubernetes Service/probe traffic reaches the process.
+ENV NODE_ENV=production \
+ STANDALONE=false \
+ HOST=0.0.0.0
ARG APP_VERSION
RUN test -n "$APP_VERSION" || (echo "APP_VERSION build-arg is required" >&2 && exit 1)
diff --git a/packages/trueforge/.env.example b/packages/trueforge/.env.example
index 7dcc44e2e..243db63b4 100644
--- a/packages/trueforge/.env.example
+++ b/packages/trueforge/.env.example
@@ -13,6 +13,9 @@
## HTTP port the server listens on. Optional, defaults to 8790.
PORT=8790
+## HTTP bind address. Optional, defaults to localhost. Production Docker images set 0.0.0.0.
+# HOST=0.0.0.0
+
## Optional override for the model catalog YAML (GET /catalog/model-providers).
## When unset, the catalog inlined at build time (catalog/model-catalog.yaml) is used.
# MODEL_CATALOG_PATH=/path/to/model-catalog.yaml
diff --git a/packages/trueforge/src/config.ts b/packages/trueforge/src/config.ts
index 32317210a..b209516eb 100644
--- a/packages/trueforge/src/config.ts
+++ b/packages/trueforge/src/config.ts
@@ -18,6 +18,8 @@ import { fileURLToPath } from 'node:url';
import envPaths from 'env-paths';
const DEFAULT_PORT = 8790;
+/** Loopback default; container images set HOST=0.0.0.0 so probes and Service traffic reach the process. */
+const DEFAULT_HOST = 'localhost';
/**
* Package root whether this module runs as `src/config.ts` (tsx) or is bundled
* into `dist/main.js` / `dist/cli.js` (`import.meta` → `dist/` → parent).
@@ -276,6 +278,8 @@ export interface SharedServerConfiguration {
NODE_ENV: string | undefined;
/** HTTP port the server listens on. Env: `PORT`. */
PORT: number;
+ /** HTTP bind address. Env: `HOST`. Default `localhost`; production images use `0.0.0.0`. */
+ HOST: string;
/** Peering identity embedded in the turn ids this process mints; `local` in standalone mode. */
EXECUTOR_ID: string;
/**
@@ -444,11 +448,13 @@ const standalone = parseBoolean({
});
const port = parsePort(getEnv('PORT'));
+const host = getEnv('HOST', { defaultValue: DEFAULT_HOST }) ?? DEFAULT_HOST;
const shared: SharedServerConfiguration = {
LOG_LEVEL: getEnv('LOG_LEVEL', { defaultValue: 'info' }) ?? 'info',
NODE_ENV: getEnv('NODE_ENV'),
PORT: port,
+ HOST: host,
EXECUTOR_ID: standalone ? LOCAL_EXECUTOR_ID : randomAlphanumeric(6),
MODEL_CATALOG_PATH: resolveOptionalPathEnv('MODEL_CATALOG_PATH'),
MCP_CATALOG_PATH: resolveOptionalPathEnv('MCP_CATALOG_PATH'),
diff --git a/packages/trueforge/src/main.ts b/packages/trueforge/src/main.ts
index 6611fc6ef..59394d1f3 100644
--- a/packages/trueforge/src/main.ts
+++ b/packages/trueforge/src/main.ts
@@ -296,8 +296,8 @@ try {
await requestReplyExecutor.init();
}
- const server = serve({ fetch: app.fetch, port: configuration.PORT }, info => {
- logger.info(`Agent server listening on http://localhost:${String(info.port)} (docs at /api/v1/docs)`);
+ const server = serve({ fetch: app.fetch, port: configuration.PORT, hostname: configuration.HOST }, info => {
+ logger.info(`Agent server listening on http://${configuration.HOST}:${String(info.port)} (docs at /api/v1/docs)`);
});
server.on('error', (error: unknown) => {