Add --host argument to adk web and adk api_server commands and change the default binding host to localhost.

PiperOrigin-RevId: 759276079
This commit is contained in:
Liang Wu 2025-05-15 13:27:17 -07:00 committed by Copybara-Service
parent 05917cabbd
commit c399c50be5
2 changed files with 19 additions and 3 deletions

View File

@ -54,7 +54,7 @@ COPY "agents/{app_name}/" "/app/agents/{app_name}/"
EXPOSE {port}
CMD adk {command} --port={port} {session_db_option} {trace_to_cloud_option} "/app/agents"
CMD adk {command} --port={port} --host=0.0.0.0 {session_db_option} {trace_to_cloud_option} "/app/agents"
"""

View File

@ -383,6 +383,13 @@ def cli_eval(
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
),
)
@click.option(
"--host",
type=str,
help="Optional. The binding host of the server",
default="127.0.0.1",
show_default=True,
)
@click.option(
"--port",
type=int,
@ -437,6 +444,7 @@ def cli_web(
session_db_url: str = "",
log_level: str = "INFO",
allow_origins: Optional[list[str]] = None,
host: str = "127.0.0.1",
port: int = 8000,
trace_to_cloud: bool = False,
reload: bool = True,
@ -489,7 +497,7 @@ def cli_web(
)
config = uvicorn.Config(
app,
host="0.0.0.0",
host=host,
port=port,
reload=reload,
)
@ -511,6 +519,13 @@ def cli_web(
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
),
)
@click.option(
"--host",
type=str,
help="Optional. The binding host of the server",
default="127.0.0.1",
show_default=True,
)
@click.option(
"--port",
type=int,
@ -567,6 +582,7 @@ def cli_api_server(
session_db_url: str = "",
log_level: str = "INFO",
allow_origins: Optional[list[str]] = None,
host: str = "127.0.0.1",
port: int = 8000,
trace_to_cloud: bool = False,
reload: bool = True,
@ -595,7 +611,7 @@ def cli_api_server(
web=False,
trace_to_cloud=trace_to_cloud,
),
host="0.0.0.0",
host=host,
port=port,
reload=reload,
)