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:

ServiceImageRole
postgrespgvector/pgvector:pg17Storage and vector search. Data lives in the mnemosyne-pgdata volume.
redisredis:7-alpineHot tier, rate limits, idempotency and session operations.
migratebuilt from docker/Dockerfile.migrateApplies the migrations once and exits. The server waits for exit 0.
serverbuilt from docker/Dockerfile.serverThe HTTP API, on PORT (3939 in .env.example).
ollamaollama/ollama:latestLocal 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/ready

Compose 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 migrate

Environment variables

Read by the server or by the Compose files. The commented list is docker/.env.example.

VariableDefault in ComposeNotes
DATABASE_URLbundled PostgresRequired: the server exits without it. In production, the mnemo_app role’s URL.
MNEMO_MIGRATION_DATABASE_URLbundled PostgresDirect superuser URL, used only by migrate.
MNEMO_REDIS_URLredis://redis:6379Hot tier, rate limits, idempotency, session operations.
MNEMO_LLM_PROVIDERopenaiopenai, anthropic, google, cohere, mistral, voyage, bedrock or ollama.
MNEMO_LLM_API_KEYnoneProvider key. Ollama needs none.
MNEMO_LLM_MODELgpt-4o-miniCompletion model for extraction and session collapse.
MNEMO_LLM_BASE_URLnoneProvider endpoint, for example the Ollama URL.
MNEMO_LLM_<TASK>_PROVIDERnone<TASK> is JUDGE, SUMMARY or PREFILTER, with _MODEL and _API_KEY: a provider per task. See Cost control.
MNEMO_LLM_DAILY_BUDGET_USDnoneDaily cap in USD on completions. See Cost control.
MNEMO_EMBED_PROVIDERnoneDedicated embedding provider, with MNEMO_EMBED_API_KEY and MNEMO_EMBED_BASE_URL.
MNEMO_EMBED_MODELtext-embedding-3-smallChanging it re-embeds existing memories in the background.
MNEMO_EMBED_DIMENSIONSdetectedMust be a width the schema declares: 1024, 1536, 2048 or 4096.
MNEMO_MASTER_KEYnoneRequired in production.
MNEMO_KEY_PEPPERnoneRequired in production.
MNEMO_DASHBOARD_SECRETnoneUnset, dashboard sign-in is off. Shorter than 32 bytes, the server refuses to start.
MNEMO_METRICS_TOKENnoneBearer token for /metrics. See Monitoring.
MNEMO_PLUGINSnoneSee Running plugins.
MNEMO_PLUGIN_<ID>__<KEY>noneOne config value for one plugin. Add each one you use to the server’s environment in Compose.
MNEMO_REGIONnoneThe region this instance serves. See Security & compliance.
PORT3939HTTP port.
MNEMO_GRPC_PORTnoneOpens 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_MS45000How 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_LEVELinfotrace, debug, info, warn or error.
OTEL_EXPORTER_OTLP_ENDPOINTnoneEnables 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.persist runs on every replica. MNEMO_CRON_DISABLE turns 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_connections busy across the cluster. From 70% it sheds export, admin and federation requests, from 85% every other route, and never recall. The answer is 503 with code fleet_shed and Retry-After: 5.
  • Shutdown. On SIGTERM or SIGINT the server stops taking work and drains, and forces the exit after MNEMO_SHUTDOWN_GRACE_MS. Keep it below the platform’s own limit: 60 seconds in fly.toml and in the production Compose file.