Skip to content

Commit da05f98

Browse files
authored
fix(server): separate compose host port overrides from runtime ports (#137)
## Summary - split Docker host port overrides onto dedicated compose env vars - keep the server container listening on port 8000 internally - align `make server-run` and docs with the separated host-port behavior ## Verification - `AGENT_CONTROL_SERVER_HOST_PORT=18000 AGENT_CONTROL_DB_HOST_PORT=15432 docker compose -f docker-compose.yml config` - `AGENT_CONTROL_DB_HOST_PORT=15432 docker compose -f docker-compose.dev.yml config` - `make -C server -n run AGENT_CONTROL_HOST=127.0.0.1 AGENT_CONTROL_PORT=18000 AGENT_CONTROL_DB_PORT=15432` ## Tests - not run (compose/make/docs change only)
1 parent 4ff2a0a commit da05f98

5 files changed

Lines changed: 30 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,23 @@ curl -L https://raw.githubusercontent.com/agentcontrol/agent-control/refs/heads/
6666
This starts PostgreSQL and Agent Control at `http://localhost:8000`, including
6767
the UI/dashboard.
6868

69+
To override the exposed host ports, set `AGENT_CONTROL_SERVER_HOST_PORT` and/or
70+
`AGENT_CONTROL_DB_HOST_PORT` before starting Compose. Example:
71+
72+
```bash
73+
export AGENT_CONTROL_SERVER_HOST_PORT=18000
74+
export AGENT_CONTROL_DB_HOST_PORT=15432
75+
curl -L https://raw.githubusercontent.com/agentcontrol/agent-control/refs/heads/main/docker-compose.yml | docker compose -f - up -d
76+
```
77+
6978
Verify it is up:
7079

7180
```bash
7281
curl http://localhost:8000/health
7382
```
7483

84+
If you changed `AGENT_CONTROL_SERVER_HOST_PORT`, use that port in the health check URL.
85+
7586
### 2. Install the SDK
7687

7788
Run this in your agent project directory.

docker-compose.dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# Usage:
77
# docker compose -f docker-compose.dev.yml up -d
8+
# AGENT_CONTROL_DB_HOST_PORT=15432 docker compose -f docker-compose.dev.yml up -d
89
# cd server && uvicorn main:app --reload
910
# OR
1011
# make server-run (handles this automatically)
@@ -16,7 +17,7 @@ services:
1617
image: postgres:16-alpine
1718
container_name: agent_control_postgres
1819
ports:
19-
- "5432:5432"
20+
- "${AGENT_CONTROL_DB_HOST_PORT:-5432}:5432"
2021
environment:
2122
POSTGRES_DB: agent_control
2223
POSTGRES_USER: agent_control

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# Quick Start:
44
# docker compose up -d
5+
# AGENT_CONTROL_SERVER_HOST_PORT=18000 AGENT_CONTROL_DB_HOST_PORT=15432 docker compose up -d
56
#
67
# Services:
78
# - PostgreSQL database (port 5432)
@@ -21,7 +22,7 @@ services:
2122
image: postgres:16-alpine
2223
container_name: agent_control_postgres
2324
ports:
24-
- "5432:5432"
25+
- "${AGENT_CONTROL_DB_HOST_PORT:-5432}:5432"
2526
environment:
2627
POSTGRES_DB: agent_control
2728
POSTGRES_USER: agent_control
@@ -40,7 +41,7 @@ services:
4041
image: galileoai/agent-control-server:latest
4142
container_name: agent_control_server
4243
ports:
43-
- "8000:8000"
44+
- "${AGENT_CONTROL_SERVER_HOST_PORT:-8000}:8000"
4445
environment:
4546
# Database connection (uses Docker service name 'postgres')
4647
# Use postgresql+psycopg:// (supports both sync migrations and async app code)

server/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ UP ?= head
77
DOWN ?= -1
88
SHOW ?= head
99
STAMP ?= head
10+
AGENT_CONTROL_HOST ?= 0.0.0.0
11+
AGENT_CONTROL_PORT ?= 8000
12+
AGENT_CONTROL_DB_PORT ?= 5432
13+
AGENT_CONTROL_DB_HOST_PORT ?= $(AGENT_CONTROL_DB_PORT)
1014

1115
TEST_DB ?= agent_control_test
1216
TEST_DB_ENV := env -u AGENT_CONTROL_DB_URL -u DATABASE_URL -u DB_URL AGENT_CONTROL_DB_HOST=localhost AGENT_CONTROL_DB_PORT=5432 AGENT_CONTROL_DB_USER=agent_control AGENT_CONTROL_DB_PASSWORD=agent_control AGENT_CONTROL_DB_DATABASE=$(TEST_DB) AGENT_CONTROL_DB_DRIVER=psycopg
1317
.PHONY: help run start-dependencies test migrate alembic-migrate alembic-revision alembic-upgrade alembic-downgrade alembic-current alembic-history alembic-heads alembic-show alembic-stamp
1418

1519
help:
1620
@echo "Available targets:"
17-
@echo " run - start FastAPI server (reload)"
21+
@echo " run - start FastAPI server (reload; honors AGENT_CONTROL_HOST/AGENT_CONTROL_PORT)"
22+
@echo " local Postgres host mapping defaults to AGENT_CONTROL_DB_PORT"
1823
@echo " start-dependencies - docker compose up -d (start local dependencies)"
1924
@echo " test - run server tests (uses $(TEST_DB_ENV))"
2025
@echo " migrate - run database migrations (alembic upgrade head)"
@@ -56,7 +61,7 @@ alembic-stamp:
5661
$(ALEMBIC) stamp $(STAMP)
5762

5863
start-dependencies:
59-
docker compose -f ../docker-compose.dev.yml up -d
64+
AGENT_CONTROL_DB_HOST_PORT=$(AGENT_CONTROL_DB_HOST_PORT) docker compose -f ../docker-compose.dev.yml up -d
6065
@echo "Waiting for PostgreSQL to be ready..."
6166
@until docker compose -f ../docker-compose.dev.yml exec -T postgres pg_isready -U agent_control -d agent_control > /dev/null 2>&1; do \
6267
sleep 1; \
@@ -67,4 +72,4 @@ test:
6772
$(TEST_DB_ENV) uv run --package agent-control-server pytest --cov=src --cov-report=xml:../coverage-server.xml -q
6873

6974
run: start-dependencies migrate
70-
uv run --package agent-control-server uvicorn agent_control_server.main:app --reload
75+
uv run --package agent-control-server uvicorn agent_control_server.main:app --reload --host $(AGENT_CONTROL_HOST) --port $(AGENT_CONTROL_PORT)

server/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ make server-run
2121

2222
Server runs on http://localhost:8000. The UI expects this base URL by default.
2323

24+
To use non-default local ports with `make server-run`, export
25+
`AGENT_CONTROL_PORT` for the server listen port. If you also want the local
26+
Postgres container exposed on a different host port, set
27+
`AGENT_CONTROL_DB_HOST_PORT` and point the server at the same value with
28+
`AGENT_CONTROL_DB_PORT`.
29+
2430
## Configuration
2531

2632
Server configuration is driven by environment variables (database, auth, observability, evaluators). For the full list and examples, see the docs.

0 commit comments

Comments
 (0)