Deploy
Mnemosyne is self-hosted. No Docker image is published to a registry: you clone
the repository and Compose builds the images from its docker/ folder. The
base file, docker/docker-compose.yml, defines five services:
| Service | Image | Role |
|---|---|---|
postgres | pgvector/pgvector:pg17 | Storage and vector search. Data lives in the mnemosyne-pgdata volume. |
redis | redis:7-alpine | Hot tier, rate limits, idempotency and session operations. |
migrate | built from docker/Dockerfile.migrate | Applies the migrations once and exits. The server waits for exit 0. |
server | built from docker/Dockerfile.server | The HTTP API, on PORT (3939 in .env.example). |
ollama | ollama/ollama:latest | Local model for completions and embeddings. |
The local stack is for trying Mnemosyne out. It connects to Postgres as the database owner, which bypasses row-level security, so workspaces are not isolated from each other. The production overlay provisions a restricted role and turns the isolation on.
git clone https://github.com/lucasmailland/mnemosyne
cd mnemosyne/docker
cp .env.example .env
docker compose up -d
docker exec mnemosyne-ollama ollama pull bge-m3 # embeddings, 1024 dimensions
docker exec mnemosyne-ollama ollama pull qwen2.5:3b # completions
curl http://localhost:3939/health/readyCompose merges docker-compose.override.yml automatically. The override
points the model and the embeddings at the bundled Ollama, so no cloud API key
is needed. It also sets NODE_ENV=development and
MNEMO_ALLOW_UNSAFE_DB_ROLE=true, which is why this stack is not for
production. Wait until /health/ready reports "embed":"ok" before the first
recall.
There is no Kubernetes manifest, Helm chart or Terraform module in the repository.
Create the first API key
The first key comes from the terminal, because every HTTP route that could mint one is itself authenticated:
docker compose exec server node scripts/create-api-key.cjs --label "prod"The key (mns_live_...) is printed once. --workspace is optional; when
given it must be a UUID, and when omitted a new workspace UUID is generated.
Migrations
The server does not apply migrations. The migrate service runs
node /app/scripts/run-migrations.mjs, which applies both migration streams
(70 migrations in the current one) and, when MNEMO_APP_DB_PASSWORD is set,
creates the mnemo_app role. The server starts only after migrate exits 0.
To run it again by hand:
docker compose run --rm migrateEnvironment variables
Read by the server or by the Compose files. The commented list is
docker/.env.example.
| Variable | Default in Compose | Notes |
|---|---|---|
DATABASE_URL | bundled Postgres | Required: the server exits without it. In production, the mnemo_app role’s URL. |
MNEMO_MIGRATION_DATABASE_URL | bundled Postgres | Direct superuser URL, used only by migrate. |
MNEMO_REDIS_URL | redis://redis:6379 | Hot tier, rate limits, idempotency, session operations. |
MNEMO_LLM_PROVIDER | openai | openai, anthropic, google, cohere, mistral, voyage, bedrock or ollama. |
MNEMO_LLM_API_KEY | none | Provider key. Ollama needs none. |
MNEMO_LLM_MODEL | gpt-4o-mini | Completion model for extraction and session collapse. |
MNEMO_LLM_BASE_URL | none | Provider endpoint, for example the Ollama URL. |
MNEMO_LLM_<TASK>_PROVIDER | none | <TASK> is JUDGE, SUMMARY or PREFILTER, with _MODEL and _API_KEY: a provider per task. See Cost control. |
MNEMO_LLM_DAILY_BUDGET_USD | none | Daily cap in USD on completions. See Cost control. |
MNEMO_EMBED_PROVIDER | none | Dedicated embedding provider, with MNEMO_EMBED_API_KEY and MNEMO_EMBED_BASE_URL. |
MNEMO_EMBED_MODEL | text-embedding-3-small | Changing it re-embeds existing memories in the background. |
MNEMO_EMBED_DIMENSIONS | detected | Must be a width the schema declares: 1024, 1536, 2048 or 4096. |
MNEMO_MASTER_KEY | none | Required in production. |
MNEMO_KEY_PEPPER | none | Required in production. |
MNEMO_DASHBOARD_SECRET | none | Unset, dashboard sign-in is off. Shorter than 32 bytes, the server refuses to start. |
MNEMO_METRICS_TOKEN | none | Bearer token for /metrics. See Monitoring. |
MNEMO_PLUGINS | none | See Running plugins. |
MNEMO_PLUGIN_<ID>__<KEY> | none | One config value for one plugin. Add each one you use to the server’s environment in Compose. |
MNEMO_REGION | none | The region this instance serves. See Security & compliance. |
PORT | 3939 | HTTP port. |
MNEMO_GRPC_PORT | none | Opens a second, cleartext HTTP/2 listener with only the gRPC service, for the bidirectional RPCs and the plain gRPC protocol. Must differ from PORT. See gRPC. |
MNEMO_SHUTDOWN_GRACE_MS | 45000 | How long the server drains after SIGTERM before it forces the exit. A value that is not a whole number of milliseconds stops the boot. |
LOG_LEVEL | info | trace, debug, info, warn or error. |
OTEL_EXPORTER_OTLP_ENDPOINT | none | Enables OpenTelemetry traces. |
Without an LLM provider the server still boots and logs a warning; POST /recall without a precomputed vector then answers 501.
Several replicas
The server keeps no state of its own, so several replicas can share one Postgres and one Redis.
- Background jobs. Each replica runs the same in-process scheduler, and
each tick of a job that touches the shared database or Redis runs on one
replica only: the first to take a Postgres advisory lock for it. The lock
lives in a transaction, so it holds through pgBouncer in transaction mode.
Only
mnemo.meter.persistruns on every replica.MNEMO_CRON_DISABLEturns jobs off by key. - Agent policies. A policy change reaches every replica’s cache within about a second, with or without Redis: each replica polls a change log in Postgres every second (migration 0067). See Agent RBAC.
- Load shedding. With Redis set, which the rate limiter needs, the server
reads every 2 seconds the share of Postgres
max_connectionsbusy across the cluster. From 70% it sheds export, admin and federation requests, from 85% every other route, and never recall. The answer is503with codefleet_shedandRetry-After: 5. - Shutdown. On
SIGTERMorSIGINTthe server stops taking work and drains, and forces the exit afterMNEMO_SHUTDOWN_GRACE_MS. Keep it below the platform’s own limit: 60 seconds infly.tomland in the production Compose file.