Skip to content

Run it with Docker

The repository’s docker-compose.yaml is a production-like stack: memento from the image ghcr.io/digital-cube/jsmemento, PostgreSQL 18 and Redis 7, with health checks and named volumes. The server applies its migrations when it starts, and the CLI is inside the image. This is the PostgreSQL stack; without Docker or a database service, run it on a SQLite file instead.

  1. Get the compose file, with the rest of the repository:

    Terminal window
    git clone https://github.com/digital-cube/jsmemento.git && cd jsmemento
  2. Give it a database password and the image to run. MEMENTO_IMAGE defaults to the latest tag, the newest release; pin a release as here, or take main, the image of the newest commit:

    Terminal window
    # .env next to docker-compose.yaml: a database password, and the release to run
    # (:latest is the newest release, :main the newest commit)
    cat > .env <<'ENV'
    POSTGRES_PASSWORD=change-me
    MEMENTO_IMAGE=ghcr.io/digital-cube/jsmemento:1.1.0
    ENV
  3. Start memento. Compose starts PostgreSQL and Redis first, because memento waits for their health checks; --wait returns when all three are healthy. Then ask the server how it is:

    Terminal window
    # memento with PostgreSQL 18 and Redis 7; --wait returns once their health checks pass
    docker compose -f docker-compose.yaml up -d --wait memento
    curl localhost:3000/memento/api/health
    What it prints
    Container jsmemento-redis-1 Healthy
    Container jsmemento-postgres-1 Healthy
    Container jsmemento-memento-1 Healthy
    {"ok":true,"data":{"status":"ok"}}

    The file has more services: service, the self-service site (accounts, keys, usage), and behind the demo profile a CPU monitor and a ticket desk simulator. Naming memento starts only what the API needs.

  4. Create a tenant, and an API key of it. A key belongs to one tenant: everything it pushes or reads is that tenant’s. read lets it list, query and stream; write lets it push.

    Terminal window
    # a tenant, and an API key of it with both scopes: the mk_… secret is printed this once
    docker compose -f docker-compose.yaml exec memento memento create-tenant acme --name "Acme Inc"
    docker compose -f docker-compose.yaml exec memento \
    memento create-key --tenant acme --scopes read,write --name backend
    What it prints
    created tenant acme (Acme Inc) id=40c1b5bc-0c20-40e2-b00a-b88dc9e3b4e5
    created key "backend" for acme [read,write]
    prefix: 27lho6hx
    key: mk_27lho6hx_…
    Store it now: it cannot be shown again.

    Only a hash of the key is stored. Copy the mk_… line now; a lost key is revoked (memento revoke-key <prefix>) and replaced, never shown again.

  5. Push the first event, and read the history of user/42 back, rendered in Serbian:

    Terminal window
    export MEMENTO_API_KEY=mk_… # what create-key printed
    curl -X POST localhost:3000/memento/events -H "Authorization: Bearer $MEMENTO_API_KEY" \
    -H 'content-type: application/json' \
    -d '{"event_type":"USER_LOGIN","instance_type":"user","instance_id":42,"actor_id":"igor"}'
    curl "localhost:3000/memento/entities/user/42/events?locale=sr" \
    -H "Authorization: Bearer $MEMENTO_API_KEY"
    What it prints
    {"ok":true,"data":{"id":"ee41fd55-c7f5-4dfa-991e-b486e6591a4d","occurred_at":"2026-11-02T00:27:43.402Z","received_at":"2026-11-02T00:27:43.430Z","event_type":"USER_LOGIN","instance_type":"user","instance_id":"42","actor_id":"igor","payload":{},"rendered":"User igor logged in.","rendered_locale":"en","archived_at":null}}
    {"ok":true,"data":[{"id":"ee41fd55-c7f5-4dfa-991e-b486e6591a4d","occurred_at":"2026-11-02T00:27:43.402Z","received_at":"2026-11-02T00:27:43.430Z","event_type":"USER_LOGIN","instance_type":"user","instance_id":"42","actor_id":"igor","payload":{},"rendered":"Korisnik igor se prijavio.","rendered_locale":"sr","archived_at":null}],"meta":{"limit":50,"count":1,"next_cursor":null}}

    memento renders rendered from the USER_LOGIN template of the asked locale, per request; the event itself is stored once and never changes.

  6. Open http://localhost:3000/: the image serves the examples site there, same origin as the API. It asks for a key: paste the one from step 4 under Settings, or give the server a read-only demo key and it connects by itself (DEMO_API_KEY, see docs/DEPLOYMENT.md). To give its pages something to show, turn on the demo profile: the CPU monitor and the simulator push into a tenant demo with a write key of it.

  7. When you are done:

    Terminal window
    docker compose -f docker-compose.yaml down # stop; the data stays in named volumes
    docker compose -f docker-compose.yaml down -v # stop and delete the data too

Every variable can go into .env. The host ports: MEMENTO_PORT (3000), SERVICE_PORT (8201), POSTGRES_PORT (5432) and REDIS_PORT (6379); PostgreSQL and Redis are published on 127.0.0.1 only. A second stack next to the first needs its own ports and its own COMPOSE_PROJECT_NAME: the file names its project jsmemento, and two stacks with one name are one stack. The whole list, the image’s tags, the service site, retention, backups and a reverse proxy in front of it: docs/DEPLOYMENT.md.

  • Push from your own code: the client programs work against this server with MEMENTO_URL=http://localhost:3000/memento.
  • Run memento inside your application instead: Embedded in Node.
  • The image on one SQLite file, with a volume and no postgres or redis service: the SQLite guide.

v1.1.0released built 663143e