From 4357da8674cb42e5332c8598d775d4432c30728e Mon Sep 17 00:00:00 2001 From: Dmitriy Barbul Date: Sat, 1 Feb 2025 17:26:33 +0200 Subject: [PATCH] Update ClusterSharding.Node example to use shared SQLite store --- .../ClusterSharding.Node/Dockerfile | 4 +-- .../ClusterSharding.Node/app.conf | 6 ++-- .../ClusterSharding.Node/docker-compose.yaml | 32 +++++++++++-------- .../ClusterSharding.Node/start.cmd | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/Dockerfile b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/Dockerfile index 3e1576abe80..092682a78b6 100644 --- a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/Dockerfile +++ b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/Dockerfile @@ -1,3 +1,3 @@ -FROM mcr.microsoft.com/dotnet/core/runtime:3.1 -COPY ["./bin/Release/netcoreapp3.1/publish", "."] +FROM mcr.microsoft.com/dotnet/runtime:8.0 +COPY ["./bin/Release/net8.0/publish", "."] ENTRYPOINT ["dotnet", "ClusterSharding.Node.dll"] diff --git a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/app.conf b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/app.conf index c72aa9b5e6e..46dd0c8a0ac 100644 --- a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/app.conf +++ b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/app.conf @@ -12,7 +12,7 @@ akka { auto-down-unreachable-after = 5s sharding { remember-entities = on - least-shard-allocation-strategy.rebalance-threshold = 3 + least-shard-allocation-strategy.rebalance-absolute-limit = 3 state-store-mode = ddata } } @@ -20,14 +20,14 @@ akka { journal { plugin = "akka.persistence.journal.sqlite" sqlite { - connection-string = "Datasource=store.db" + connection-string = "Datasource=/data/store.db" auto-initialize = true } } snapshot-store { plugin = "akka.persistence.snapshot-store.sqlite" sqlite { - connection-string = "Datasource=store.db" + connection-string = "Datasource=/data/store.db" auto-initialize = true } } diff --git a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/docker-compose.yaml b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/docker-compose.yaml index c5b2070d7a8..b3094e0dc7a 100644 --- a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/docker-compose.yaml +++ b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/docker-compose.yaml @@ -1,32 +1,36 @@ -version: '3.7' - services: node-1: image: cluster-sharding:latest - network_mode: host ports: - - '6055:6055' + - '6055' environment: - CLUSTER_IP: "localhost" + CLUSTER_IP: "node-1" CLUSTER_PORT: 6055 - CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@localhost:6055" + CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@node-1:6055" + volumes: + - data:/data:rw node-2: image: cluster-sharding:latest - network_mode: host ports: - - '6056:6056' + - '6056' environment: - CLUSTER_IP: "localhost" + CLUSTER_IP: "node-2" CLUSTER_PORT: 6056 - CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@localhost:6055" + CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@node-1:6055" + volumes: + - data:/data:rw node-3: image: cluster-sharding:latest - network_mode: host ports: - - '6057:6057' + - '6057' environment: - CLUSTER_IP: "localhost" + CLUSTER_IP: "node-3" CLUSTER_PORT: 6057 - CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@localhost:6055" + CLUSTER_SEEDS: "akka.tcp://sharded-cluster-system@node-1:6055" + volumes: + - data:/data:rw + +volumes: + data: ~ diff --git a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/start.cmd b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/start.cmd index 407dfe28acd..0c1ba578f80 100644 --- a/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/start.cmd +++ b/src/examples/Cluster/ClusterSharding/ClusterSharding.Node/start.cmd @@ -1,3 +1,3 @@ dotnet publish -c Release docker build -t cluster-sharding:latest . -docker-compose up +docker compose up