Mirexa

Wiki Operations

Deploying with Docker Compose

The shipped Compose stack — node, dashboard API and nginx proxy — what it publishes, the secrets it needs, volume ownership, and how cluster deployments differ.

The repository ships one deployment: a Docker Compose stack in deploy/ that runs a single Mirexa node, the dashboard API in front of it, and an nginx proxy that serves the dashboard's web application. Exactly one port is published, on loopback. Compose is the whole of what the repository provides; there are no Kubernetes manifests, Helm charts or install scripts, by decision.

The shape

flowchart TD
  B[Browser] -->|"127.0.0.1:8080"| W["web: nginx + SPA<br/>(only published port)"]
  W -->|"/api, compose network"| D["dashboard: mirexa-dashboard<br/>:8080 API, :9101 metrics"]
  D -->|"wire protocol, compose network"| N["mirexa: mirexa-server<br/>:9200 wire, :9201 observability"]
  N --- V[("volume mirexa-data<br/>/var/lib/mirexa")]
Service Image target Listens (inside the network) Published
mirexa mirexa 9200 wire protocol, 9201 /metrics /health /ready no
dashboard dashboard 8080 API, 9101 its own metrics no
web web 80 127.0.0.1:8080 → 80

mirexa and dashboard have no ports: entry; they are reachable only on the Compose network. A test fails if either ever gains one.[1] The health checks chain the startup: dashboard waits for mirexa's /health, and web waits for dashboard's.

Why a proxy

The dashboard's refresh cookie is named with the __Host- prefix and is SameSite=Strict, so a browser sends it only when the page and the API share an origin. nginx gives them one: it serves the built SPA and proxies /api/ to the dashboard. Serving the SPA from another host or port silently loses the cookie, and a page reload then signs the user out. See the web dashboard.

The nginx configuration also:

  • resolves the dashboard's name per request (Docker's DNS at 127.0.0.11, 10-second validity), so the proxy starts while the dashboard is down and follows it when it is replaced;
  • sends a strict Content-Security-Policy, X-Frame-Options: DENY, nosniff and no-referrer on the document;
  • never caches index.html and caches content-hashed /assets/ for a year;
  • passes the live chart's Server-Sent Events endpoint unbuffered with one-hour timeouts;
  • forwards X-Forwarded-For and X-Real-IP (the dashboard does not currently read them: its login throttle keys on the proxy's address, so failed sign-ins from anyone count against everyone — see the web dashboard);
  • exposes the dashboard's /health but not /ready.

What you must supply

The committed files are deliberately not a working deployment: four things are secrets or site-specific.

  1. A signing keypair, kept off this host. Generate it with mirexa-cli token keygen and paste the printed public key into deploy/config/node.yaml as public_key: — an inline base64 value, not a path. The private key mints any permission and belongs elsewhere.

    bash
    mirexa-cli token keygen -dir /somewhere/safe -name ops
    
  2. The dashboard's token file, deploy/secrets/upstream_token, issued from that key. Tokens live at most one hour, so something outside the stack must rewrite this file before it lapses; the dashboard re-reads it on every reconnect.

    bash
    mirexa-cli token issue -key /somewhere/safe/ops.key -perms READ_CANDLES,WRITE_CANDLES,LIST_STREAMS -validity 60m > deploy/secrets/upstream_token
    
  3. A session secret, deploy/secrets/session_secret, at least 32 bytes. It signs browser sessions; replacing it signs everyone out at once.

    bash
    head -c 32 /dev/urandom | base64 > deploy/secrets/session_secret
    
  4. A password hash in deploy/config/dashboard.yaml in place of REPLACE-ME:

    bash
    mirexa-dashboard -hash-password
    

Then build and start:

bash
docker compose -f deploy/docker-compose.yml up --build

and open http://127.0.0.1:8080.

Secrets and volumes

Mount Into Mode Holds
volume mirexa-data mirexa:/var/lib/mirexa read-write all node data
./config/node.yaml mirexa:/etc/mirexa/node.yaml read-only node configuration (public key only)
./config/dashboard.yaml dashboard:/etc/mirexa/dashboard.yaml read-only dashboard configuration and password hashes
./secrets/ dashboard:/etc/mirexa/secrets/ read-only session_secret, upstream_token
  • No key material is baked into an image. Tests fail if the Dockerfile copies a secret, if key material is committed, or if the example configs carry a usable password hash or trusted key.[2]
  • Volume ownership. The node runs as uid 10001. The image creates /var/lib/mirexa owned by that uid, and Docker copies that ownership onto the named volume on first mount. If you replace the named volume with a bind mount, make the host directory writable by uid 10001 yourself; otherwise every write fails with "permission denied" and the node reports unhealthy.
  • Back up the volume, not the containers. A consistent copy needs the node stopped (a clean stop drains the hot caches into chunks); a copy of a running node's directory is a crash image, which recovery replays from the WAL (see startup, shutdown and recovery). There is no online backup tool.

What the example configures

deploy/config/node.yaml keeps authentication on (the default) with a trusted key of its own, so the node generates no issuer of its own, binds the wire protocol to 0.0.0.0:9200 and observability to 0.0.0.0:9201 inside the container — privacy comes from not publishing those ports — and sets security.max_permissions to READ_CANDLES, WRITE_CANDLES, LIST_STREAMS. deploy/config/dashboard.yaml points the dashboard at mirexa:9200, sets session_cookie_secure: false because the example serves plain HTTP, and leaves upstream_tls: false because the hop stays inside one Docker network.

Before calling it production

  1. Terminate TLS in front of nginx, publish 443 instead of loopback 8080, and set session_cookie_secure: true. That flag also turns on HSTS; setting it without TLS in front tells browsers to refuse plain HTTP to the host for a year.
  2. Set upstream_tls: true (and give the node a certificate) if the dashboard and node do not share a private network: the dashboard's token is a bearer credential anyone on the path could replay until it expires.
  3. Narrow security.max_permissions to what the dashboard needs. It applies whether or not auth is on.
  4. Automate the token refresh for upstream_token. When it lapses every dashboard request answers 503; see troubleshooting.
  5. Add monitoring. Prometheus, Alertmanager and Grafana are not in this stack; point a scraper at mirexa:9201 and dashboard:9101 on the Compose network. See monitoring.

Variations

  • An existing node elsewhere. Point upstream_addr at it and remove the mirexa service and volume from the Compose file by hand; the file always starts a node.
  • Without the dashboard. Run only the mirexa service and publish its wire port — ideally on a private address, with auth on.
  • A cluster. The Compose file runs one node. A cluster needs each node to have a unique cluster.node_id, a Raft address its peers can dial, a control listener, and (for copies) a replication listener with its own mTLS certificate from mirexa-cli certs. Give each node its own volume. No cluster Compose file or orchestration manifest is provided; see operating a cluster for the per-node configuration and TLS for certificates.

Why no Kubernetes manifests

A single Mirexa node owns a local data directory, so a manifest for it is a StatefulSet of one. A cluster's members join through cluster.seeds and coordinate through their own control plane; an orchestrator adds restart and placement, which the Compose file and this page already describe the inputs for (images, mounts, secrets, ports, probes). Nothing in the repository writes or tests manifests, so none is shipped.

References

Source

Tests

  • TestDeploy_OnlyTheProxyPublishesAPort, TestDeploy_TheProxyBindsLoopbackByDefault, TestDeploy_SSEIsNotBuffered, TestDeploy_TheSPAFallbackExists, TestDeploy_IndexHTMLIsNotCached (/deploy/image_secrets_test.go).
  • TestDeploy_NoKeyMaterialIsCommitted, TestDeploy_TheDockerfileCopiesNoSecrets, TestDeploy_TheDashboardConfigShipsNoUsablePassword, TestDeploy_TheExampleNodeConfigShipsNoRealTrustedKey, TestDeploy_AuthIsEnabledInTheExampleNodeConfig (same file).

Further reading

External


  1. TestDeploy_OnlyTheProxyPublishesAPort in /deploy/image_secrets_test.go. ↩︎

  2. The TestDeploy_* secret tests in /deploy/image_secrets_test.go. ↩︎