Database setup with Docker
Run a local PostgreSQL database with pgvector for MemoGrafter using a minimal Docker Compose setup.
Prerequisites
5432.Compose file without Redis
For normal package usage, create compose.yml in your application directory with only PostgreSQL and pgvector. Redis is optional and is not required to run MemoGrafter.
services:
postgres:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: memografter
POSTGRES_PASSWORD: memografter
POSTGRES_DB: memografter
ports:
- "5432:5432"
volumes:
- memografter_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U memografter -d memografter"]
interval: 5s
timeout: 5s
retries: 10
volumes:
memografter_postgres_data:Compose file with Redis
Contributors, or package users testing queue mode and the optional recall cache, can use this expanded compose.yml. It keeps the same PostgreSQL setup and adds Redis.
Set REDIS_URL=redis://localhost:6379 only when enabling a Redis-backed MemoGrafter feature.
services:
postgres:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: memografter
POSTGRES_PASSWORD: memografter
POSTGRES_DB: memografter
ports:
- "5432:5432"
volumes:
- memografter_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U memografter -d memografter"]
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- memografter_redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 10
volumes:
memografter_postgres_data:
memografter_redis_data:Start PostgreSQL
Start the container in the background. Docker downloads the image automatically the first time.
docker compose up -dConfigure MemoGrafter
Set DATABASE_URL in your server environment. Its username, password, port, and database name must match the Compose file.
DATABASE_URL=postgresql://memografter:memografter@localhost:5432/memografterInitialize and migrate
Initialize MemoGrafter, then create or update its database schema. The migration manages MemoGrafter-owned tables and enables required PostgreSQL extensions, including vector.
npx memo-grafter init
npx memo-grafter migrateVerify the setup
Run the doctor command to check the configuration and database connection.
npx memo-grafter doctorCommon Docker commands
# Show container status
docker compose ps
# Follow PostgreSQL logs
docker compose logs -f postgres
# Stop and remove the containers
docker compose downReset the local database
Use this only when you intentionally want a completely fresh local database, for example after changing the configured PostgreSQL credentials.
This permanently deletes your local database data
The -v flag removes the named PostgreSQL volume, including every MemoGrafter table and all locally stored memory. This cannot be undone unless you have a backup.
docker compose down -vCommon failures
5432 already in use: stop the other PostgreSQL service or map another host port, such as 5433:5432, and use that port in DATABASE_URL.docker compose up -d.docker compose ps and docker compose logs postgres; wait for startup to finish and check the environment values and available disk space.DATABASE_URL mismatch: make its username, password, host port, and database name match POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, and the Compose port mapping.CREATE EXTENSION vector.POSTGRES_* values only when initializing an empty data directory. Reuse the original credentials, or intentionally reset the volume after backing up any data you need.Package users and contributors
Package users should start with the PostgreSQL-only Compose file. It contains everything required for ordinary MemoGrafter usage.
The PostgreSQL-and-Redis Compose file is intended for contributors and users testing queue mode, caching, and integrations. Adding Redis does not make it mandatory for the rest of MemoGrafter.