1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright 2026 AlphaOne LLC
# SPDX-License-Identifier: Apache-2.0
#
# Postgres + pgvector fixture for the SAL integration test suite (v0.7).
#
# Usage (from the repo root):
#
# docker compose -f packaging/docker-compose.postgres.yml up -d
# export AI_MEMORY_TEST_POSTGRES_URL=postgres://ai_memory:ai_memory_test@localhost:5433/ai_memory_test
# cargo test --features sal-postgres --test sal_postgres -- --nocapture
# docker compose -f packaging/docker-compose.postgres.yml down -v
#
# Port 5433 is used instead of the default 5432 to avoid colliding with
# a host Postgres. Override via the `POSTGRES_HOST_PORT` env var.
services:
postgres:
# pgvector/pgvector bundles the vector extension with a recent
# Postgres 16 base image. Pinned by major version — pgvector semver
# has been stable on the 0.7+ release line so this image is safe to
# re-pull.
image: pgvector/pgvector:pg16
container_name: ai_memory_sal_postgres
restart: unless-stopped
environment:
POSTGRES_USER: ai_memory
POSTGRES_PASSWORD: ai_memory_test
POSTGRES_DB: ai_memory_test
# Speeds up test setup on the fixture only — NEVER flip these on
# for a production Postgres.
POSTGRES_INITDB_ARGS: "--data-checksums"
ports:
- "${POSTGRES_HOST_PORT:-5433}:5432"
volumes:
- pg_data:/var/lib/postgresql/data
healthcheck:
test:
interval: 2s
timeout: 5s
retries: 20
# Hardening for the fixture — even a local test DB shouldn't ship
# with unnecessary caps or write access to the host.
cap_drop:
cap_add:
security_opt:
- no-new-privileges:true
read_only: false
tmpfs:
- /tmp
- /var/run/postgresql
volumes:
pg_data:
driver: local