Deployment

MLambda.Data.Service is the database as one static Linux executable, in an Alpine image. The same image is every node; its environment decides what it is.

The image

cd MLambda.Data.Service
docker build -f Dockerfile -t mlambda-data ../../..

The build context is the folder that holds MLambda.Aleph, MLambda.Actors and MLambda.Data side by side. The Dockerfile compiles the service with the native Aleph compiler image (aleph-build, or another through --build-arg ALEPH_IMAGE=...), links it statically against musl and OpenSSL, and ships the binary on Alpine. docker build --target test runs the database’s specs on Linux instead.

A single node

docker run --rm -p 8080:8080 -v mlambda-data:/data mlambda-data
curl http://localhost:8080/health

The data lives in the /data volume and survives a restart.

The topologies

Each compose file starts servers and a client that runs the end-to-end scenarios against them and exits with the verdict:

File Nodes
compose.standalone.yml One server, its ring of one
compose.hybrid.yml One hybrid node (a cluster node hosting its own replica)
compose.cluster.yml Three hybrid nodes, one ring, every record on all three replicas

Every topology but standalone is sealed: its identities service issues each node’s identity from the cluster’s CA before any node starts (the CA’s key in a volume no node mounts).

docker compose -f compose.cluster.yml up --build --abort-on-container-exit --exit-code-from client
./test-docker.sh          # the specs on Linux, every topology, then a restart pass

test-docker.sh also stops the servers, starts them again on their volumes, and runs the client a second time (DATA_PHASE=verify) to check the table and the record the first pass left.

A cluster node, as compose.cluster.yml writes it:

x-node: &node
  DATA_ROLE: server
  ACTOR_TOPOLOGY: hybrid
  NODE_PORT: "5000"
  DATA_NODES: "data-1;data-2;data-3"

services:
  data-1:
    volumes: [data-1-store:/data]
    environment:
      <<: *node
      NODE_ID: data-1
      NODE_HOST: data-1
      SEEDS: "data-2:5000;data-3:5000"

Environment variables

Variable Meaning Default
DATA_ROLE server, or client (the scenario runner) server
HTTP_PORT The API’s port 8080
MLAMBDA_DATA_PATH The data root the working folder (/data in the image)
MLAMBDA_JWT_KEY The key access tokens are signed with a built-in development key
DATA_NODES The ring’s nodes, n1;n2;n3 this node alone
ACTOR_TOPOLOGY standalone, cluster or hybrid standalone
NODE_ID, NODE_HOST, NODE_PORT This node’s name, host and actor port (a hybrid node also uses the next two) local, 127.0.0.1, 5000
SEEDS The other nodes, host:port;host:port none
FORTRESS_IDENTITY The node’s identity file, issued by the cluster’s CA: every connection between nodes is sealed none: a cluster node refuses
TARGETS, STARTUP_DELAY, DATA_PHASE The client’s servers, start delay and pass (write or verify)  

Ports

Port Use
HTTP_PORT (8080) REST API and the live channels (/ws/metrics, /ws/ring, /ws/cluster, /ws/alerts, /ws/compaction)
NODE_PORT (5000) The actor transport between nodes
NODE_PORT + 1, + 2 A hybrid node’s satellite and client

Production checklist

  • Give every node a volume for /data.
  • Set MLAMBDA_JWT_KEY from a secret store; the built-in key is for development.
  • Issue every node its identity from one CA (fortress-issue ca, then fortress-issue nodes), keep the CA’s key off the nodes, and give each node its file as FORTRESS_IDENTITY (compose.cluster.yml’s identities does this).
  • List every node in DATA_NODES, the same list everywhere, and give each the others as SEEDS.
  • Run ./test-docker.sh against an image before you ship it.