diff --git a/.env b/.env index abb7f0e..488839c 100644 --- a/.env +++ b/.env @@ -4,3 +4,4 @@ AWS_SECRET_ACCESS_KEY=testkey ANY_SYNC_NODE_VERSION=latest ANY_SYNC_FILENODE_VERSION=latest ANY_SYNC_COORDINATOR_VERSION=latest +ANY_SYNC_CONSENSUSNODE_VERSION=latest diff --git a/Makefile b/Makefile index 77497cf..d8fd7b1 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,14 @@ generate_etc: install -d \ tmp/etc/any-sync-node-{1..3}/ \ tmp/etc/any-sync-filenode/ \ - tmp/etc/any-sync-coordinator/ + tmp/etc/any-sync-coordinator/ \ + tmp/etc/any-sync-consensusnode/ cat etc/{network,common,node-1}.yml > tmp/etc/any-sync-node-1/config.yml cat etc/{network,common,node-2}.yml > tmp/etc/any-sync-node-2/config.yml cat etc/{network,common,node-3}.yml > tmp/etc/any-sync-node-3/config.yml cat etc/{network,common,filenode}.yml > tmp/etc/any-sync-filenode/config.yml cat etc/{network,common,coordinator}.yml > tmp/etc/any-sync-coordinator/config.yml + cat etc/{network,common,consensusnode}.yml > tmp/etc/any-sync-consensusnode/config.yml cat etc/network.yml | grep -v '^network:' > tmp/etc/any-sync-coordinator/network.yml start: generate_etc diff --git a/README.md b/README.md index d10166d..e140bab 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,24 @@ docker compose exec any-sync-coordinator bash ``` +* get current network config + ``` + docker compose exec mongo mongosh coordinator + db.nodeConf.find().sort( { _id: -1 } ).limit(1) + ``` + ## set specific versions use file .env ### minimal versions * any-sync-coordinator v0.0.10 * any-sync-filenode v0.1.5 * any-sync-node v0.0.31 +* any-sync-consensusnode v0.0.4 ## usage "local build" images * clone repos ``` - install -d repos && for REPO in any-sync-{node,filenode,coordinator}; do if [[ ! -d repos/$REPO ]]; then git clone git@github.com:anyproto/${REPO}.git repos/$REPO; fi; done + install -d repos && for REPO in any-sync-{node,filenode,coordinator,consensusnode}; do if [[ ! -d repos/$REPO ]]; then git clone git@github.com:anyproto/${REPO}.git repos/$REPO; fi; done ``` * create a symlink to the "override file" you need (or you can create docker-compose.override.yml by your self) ``` diff --git a/docker-compose.any-sync-consensusnode.yml b/docker-compose.any-sync-consensusnode.yml new file mode 100644 index 0000000..9262a4b --- /dev/null +++ b/docker-compose.any-sync-consensusnode.yml @@ -0,0 +1,11 @@ +version: "3.9" +services: + any-sync-consensusnode: + image: localbuild-consensusnode + build: + context: . + dockerfile: Dockerfile + ssh: + - default + args: + REPO_DIR: repos/any-sync-consensusnode/ diff --git a/docker-compose.yml b/docker-compose.yml index 9ec075d..c271f46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,30 @@ version: "3.9" services: - mongo: + mongo-1: image: mongo + command: --replSet rs0 ports: - - 27017:27017 + - 27010:27017 volumes: - - ./tmp/mongo/:/data/db + - ./tmp/mongo-1/:/data/db + healthcheck: + test: test $$(echo "rs.initiate({_id:'rs0',members:[{_id:0,host:\"mongo-1:27017\"},{_id:1,host:\"mongo-2:27017\"},{_id:2,host:\"mongo-3:27017\"}]}).ok || rs.status().ok" | mongosh --port 27017 --quiet) -eq 1 + interval: 10s + start_period: 30s + mongo-2: + image: mongo + command: --replSet rs0 + ports: + - 27011:27017 + volumes: + - ./tmp/mongo-2/:/data/db + mongo-3: + image: mongo + command: --replSet rs0 + ports: + - 27012:27017 + volumes: + - ./tmp/mongo-3/:/data/db redis: container_name: redis image: redis:latest @@ -23,15 +42,15 @@ services: - ./tmp/s3_root:/s3_root any-sync-coordinator_bootstrap: image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}" - depends_on: [mongo] + depends_on: [mongo-1] restart: "no" volumes: - ./tmp/etc/any-sync-coordinator/:/etc/any-sync-coordinator/ - command: /bin/any-sync-confapply -c /etc/any-sync-coordinator/config.yml -n /etc/any-sync-coordinator/network.yml -e + command: bash -c "sleep 10; /bin/any-sync-confapply -c /etc/any-sync-coordinator/config.yml -n /etc/any-sync-coordinator/network.yml -e" any-sync-coordinator: image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}" depends_on: - - mongo + - mongo-1 - any-sync-coordinator_bootstrap ports: - 4435:443 @@ -43,7 +62,7 @@ services: resources: limits: memory: 500M - command: bash -c "sleep 5; /bin/any-sync-coordinator -c /etc/any-sync-coordinator/config.yml" + command: bash -c "sleep 10; /bin/any-sync-coordinator -c /etc/any-sync-coordinator/config.yml" any-sync-filenode: image: "ghcr.io/anyproto/any-sync-filenode:${ANY_SYNC_FILENODE_VERSION}" depends_on: @@ -61,7 +80,7 @@ services: resources: limits: memory: 500M - command: bash -c "sleep 10; /bin/any-sync-filenode -c /etc/any-sync-filenode/config.yml" + command: bash -c "sleep 15; /bin/any-sync-filenode -c /etc/any-sync-filenode/config.yml" any-sync-node-1: image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}" depends_on: [any-sync-coordinator] @@ -77,7 +96,7 @@ services: resources: limits: memory: 500M - command: bash -c "sleep 10; /bin/any-sync-node -c /etc/any-sync-node/config.yml" + command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml" any-sync-node-2: image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}" depends_on: [any-sync-coordinator] @@ -93,7 +112,7 @@ services: resources: limits: memory: 500M - command: bash -c "sleep 10; /bin/any-sync-node -c /etc/any-sync-node/config.yml" + command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml" any-sync-node-3: image: "ghcr.io/anyproto/any-sync-node:${ANY_SYNC_NODE_VERSION}" depends_on: [any-sync-coordinator] @@ -109,4 +128,18 @@ services: resources: limits: memory: 500M - command: bash -c "sleep 10; /bin/any-sync-node -c /etc/any-sync-node/config.yml" + command: bash -c "sleep 15; /bin/any-sync-node -c /etc/any-sync-node/config.yml" + any-sync-consensusnode: + image: "ghcr.io/anyproto/any-sync-consensusnode:${ANY_SYNC_CONSENSUSNODE_VERSION}" + depends_on: [any-sync-coordinator] + ports: + - 4436:443 + - 8006:8000 + volumes: + - ./tmp/etc/any-sync-consensusnode/:/etc/any-sync-consensusnode/ + - ./tmp/networkStore/any-sync-consensusnode/:/networkStore/ + deploy: + resources: + limits: + memory: 500M + command: bash -c "sleep 15; /bin/any-sync-consensusnode -c /etc/any-sync-consensusnode/config.yml" diff --git a/etc/consensusnode.yml b/etc/consensusnode.yml new file mode 100644 index 0000000..30c2ba3 --- /dev/null +++ b/etc/consensusnode.yml @@ -0,0 +1,22 @@ + +account: + peerId: 12D3KooWNT4hbNKXeFuDtdQ13ZbhQ1oJJ2AVWgAQVRrCj6Zb5wxk + peerKey: 5Btn70kUmMokNhSDhu3GzuFcbLxK9aRnoyb/zPWkLvu7svtWJZxQDJ5AWYZ4TxGhgb/GbZB1nPjp7Kz+V+J4OQ== + signingKey: 0ojibPdVZUL9hJmaQHpRBJYjH0Y0MuoLL+Lc2hFchorGS26RaLuUVs36ikGDDRi39BlzafEDNomB+IrBt8HCdA== + +mongo: + connect: mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/?w=majority + database: consensus + log: log + +drpc: + stream: + timeoutMilliseconds: 1000 + maxMsgSizeMb: 256 + +yamux: + listenAddrs: + - any-sync-consensusnode:443 + writeTimeoutSec: 10 + dialTimeoutSec: 10 + diff --git a/etc/coordinator.yml b/etc/coordinator.yml index 35c7725..4299073 100644 --- a/etc/coordinator.yml +++ b/etc/coordinator.yml @@ -5,7 +5,7 @@ account: signingKey: 0ojibPdVZUL9hJmaQHpRBJYjH0Y0MuoLL+Lc2hFchorGS26RaLuUVs36ikGDDRi39BlzafEDNomB+IrBt8HCdA== mongo: - connect: mongodb://mongo:27017 + connect: mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/ database: coordinator log: log spaces: spaces diff --git a/etc/network.yml b/etc/network.yml index 9c4ca6a..a4367a1 100644 --- a/etc/network.yml +++ b/etc/network.yml @@ -16,3 +16,6 @@ network: - peerId: 12D3KooWMwE15iEG51Sewt2zYqwgbrBz6QMuFVdWLBMes1SADtCh addresses: [ "any-sync-filenode:443" ] types: [file] + - peerId: 12D3KooWNT4hbNKXeFuDtdQ13ZbhQ1oJJ2AVWgAQVRrCj6Zb5wxk + addresses: [ "any-sync-consensusnode:443" ] + types: [consensus]