mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
docs(installer): use pgvector image for Postgres compose (#840)
Signed-off-by: rudi193-cmd <rudi193@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Drew Cain <groksrc@gmail.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# Docker Compose configuration for Basic Memory with PostgreSQL
|
||||
# Use this for local development and testing with Postgres backend
|
||||
# Use this for local development and testing with Postgres backend.
|
||||
#
|
||||
# The Postgres backend requires the pgvector extension (semantic search).
|
||||
# This image bundles pgvector; plain postgres:17 will not work for vector search.
|
||||
#
|
||||
# Usage:
|
||||
# docker-compose -f docker-compose-postgres.yml up -d
|
||||
@@ -7,7 +10,7 @@
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17
|
||||
image: pgvector/pgvector:pg17
|
||||
container_name: basic-memory-postgres
|
||||
environment:
|
||||
# Local development/test credentials - NOT for production
|
||||
|
||||
@@ -263,6 +263,7 @@ The sqlite-vec extension is loaded per-connection. Vector tables are created laz
|
||||
### Postgres (cloud)
|
||||
|
||||
- **Vector storage**: [pgvector](https://github.com/pgvector/pgvector) with HNSW indexing
|
||||
- **Local Docker**: use `docker-compose-postgres.yml` (`pgvector/pgvector:pg17`). Plain `postgres:17` lacks the extension; run `CREATE EXTENSION IF NOT EXISTS vector;` on any external instance before first migration.
|
||||
- **Chunk metadata table**: Created via Alembic migration (`search_vector_chunks` with `BIGSERIAL` primary key)
|
||||
- **Embedding table**: `search_vector_embeddings` created at runtime (dimension-dependent, same pattern as SQLite)
|
||||
- **Index**: HNSW index on the embedding column for fast approximate nearest-neighbour queries
|
||||
|
||||
+12
-6
@@ -10,6 +10,8 @@ pytest
|
||||
|
||||
# Run tests against Postgres only (requires docker-compose)
|
||||
docker-compose -f docker-compose-postgres.yml up -d
|
||||
BASIC_MEMORY_TEST_POSTGRES=1 \
|
||||
POSTGRES_TEST_URL=postgresql+asyncpg://basic_memory_user:dev_password@localhost:5433/basic_memory \
|
||||
pytest -m postgres
|
||||
|
||||
# Run tests against BOTH backends
|
||||
@@ -54,7 +56,7 @@ database_url = None # Uses default SQLite path
|
||||
|
||||
# Postgres config
|
||||
database_backend = DatabaseBackend.POSTGRES
|
||||
database_url = "postgresql+asyncpg://basic_memory_user:dev_password@localhost:5433/basic_memory_test"
|
||||
database_url = "postgresql+asyncpg://basic_memory_user:dev_password@localhost:5433/basic_memory"
|
||||
```
|
||||
|
||||
## Running Postgres Tests
|
||||
@@ -66,18 +68,22 @@ docker-compose -f docker-compose-postgres.yml up -d
|
||||
```
|
||||
|
||||
This starts:
|
||||
- Postgres 17 on port **5433** (not 5432 to avoid conflicts)
|
||||
- Test database: `basic_memory_test`
|
||||
- Postgres 17 with **pgvector** (`pgvector/pgvector:pg17`) on port **5433** (not 5432 to avoid conflicts)
|
||||
- Database: `basic_memory`
|
||||
- Credentials: `basic_memory_user` / `dev_password`
|
||||
|
||||
### 2. Run Postgres Tests
|
||||
|
||||
```bash
|
||||
# Run only Postgres tests
|
||||
BASIC_MEMORY_TEST_POSTGRES=1 \
|
||||
POSTGRES_TEST_URL=postgresql+asyncpg://basic_memory_user:dev_password@localhost:5433/basic_memory \
|
||||
pytest -m postgres
|
||||
|
||||
# Run specific test with Postgres
|
||||
pytest tests/test_entity_repository.py::test_create -m postgres
|
||||
BASIC_MEMORY_TEST_POSTGRES=1 \
|
||||
POSTGRES_TEST_URL=postgresql+asyncpg://basic_memory_user:dev_password@localhost:5433/basic_memory \
|
||||
pytest tests/repository/test_entity_repository.py::test_create -m postgres
|
||||
|
||||
# Skip Postgres tests (default behavior)
|
||||
pytest -m "not postgres"
|
||||
@@ -121,7 +127,7 @@ jobs:
|
||||
# Postgres service container
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17
|
||||
image: pgvector/pgvector:pg17
|
||||
env:
|
||||
POSTGRES_DB: basic_memory_test
|
||||
POSTGRES_USER: basic_memory_user
|
||||
@@ -169,4 +175,4 @@ docker-compose -f docker-compose-postgres.yml exec postgres pg_isready -U basic_
|
||||
|
||||
- [ ] Add `--run-all-backends` CLI flag to run both backends in sequence
|
||||
- [ ] Implement test fixtures for backend-specific features (e.g., Postgres full-text search vs SQLite FTS5)
|
||||
- [ ] Add performance comparison benchmarks between backends
|
||||
- [ ] Add performance comparison benchmarks between backends
|
||||
|
||||
Reference in New Issue
Block a user