Skip to content

Commit 45a33a5

Browse files
fix(server): use plain psycopg with OS libpq (#241)
1 parent 2f1e5fe commit 45a33a5

5 files changed

Lines changed: 32 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ jobs:
4242
- name: Setup uv
4343
uses: astral-sh/setup-uv@v4
4444

45+
- name: Install libpq runtime
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y --no-install-recommends libpq5
49+
4550
- name: Show versions
4651
run: |
4752
uv --version

.github/workflows/docker-publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ jobs:
5454
context: .
5555
file: server/Dockerfile
5656
platforms: linux/amd64
57+
load: ${{ github.event_name == 'pull_request' }}
5758
push: ${{ github.event_name != 'pull_request' }}
5859
tags: ${{ steps.meta.outputs.tags }}
5960
labels: ${{ steps.meta.outputs.labels }}
6061
cache-from: type=gha
6162
cache-to: type=gha,mode=max
63+
64+
- name: Smoke test psycopg runtime
65+
if: github.event_name == 'pull_request'
66+
env:
67+
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
68+
run: |
69+
image="$(printf '%s\n' "$IMAGE_TAGS" | head -n 1)"
70+
docker run --rm --entrypoint python "$image" -c 'import os; import psycopg; from psycopg import pq; assert os.environ["PSYCOPG_IMPL"] == "python"; assert pq.version() > 0; print(f"psycopg {psycopg.__version__}, libpq {pq.version()}")'

server/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2828

2929
WORKDIR /app
3030

31+
RUN apt-get update \
32+
&& apt-get install -y --no-install-recommends libpq5 \
33+
&& rm -rf /var/lib/apt/lists/*
34+
3135
# Configure uv environment variables
3236
ENV UV_COMPILE_BYTECODE=1
3337
ENV UV_LINK_MODE=copy
@@ -75,6 +79,7 @@ ENV PATH="/app/.venv/bin:$PATH"
7579
# Set default environment variables
7680
ENV AGENT_CONTROL_HOST=0.0.0.0
7781
ENV AGENT_CONTROL_PORT=8000
82+
ENV PSYCOPG_IMPL=python
7883

7984
# Expose the port
8085
EXPOSE 8000

server/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ agent-control-migrate current
4242
agent-control-migrate upgrade head
4343
```
4444

45+
## PostgreSQL driver runtime
46+
47+
`agent-control-server` depends on plain `psycopg`. The published Docker image
48+
installs Debian `libpq5` and sets `PSYCOPG_IMPL=python` so the server uses
49+
psycopg's Python implementation with the OS libpq library.
50+
51+
For wheel-based deployments outside Docker, either install the OS libpq runtime
52+
package for your platform, or install `agent-control-server[binary]` if you want
53+
psycopg's bundled binary package.
54+
4555
## Configuration
4656

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

server/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies = [
1616
"pydantic>=2.5.0",
1717
"pydantic-settings>=2.1.0",
1818
"SQLAlchemy>=2.0.0",
19-
"psycopg[binary]>=3.1",
19+
"psycopg>=3.1",
2020
"asyncpg>=0.29.0",
2121
"greenlet>=3.0",
2222
"alembic>=1.13.0",
@@ -34,6 +34,8 @@ license = {text = "Apache-2.0"}
3434

3535
[project.optional-dependencies]
3636
galileo = ["agent-control-evaluator-galileo>=7.5.0"]
37+
binary = ["psycopg[binary]>=3.1"]
38+
c = ["psycopg[c]>=3.1"]
3739

3840
[dependency-groups]
3941
dev = [

0 commit comments

Comments
 (0)