Files
hpcore/test/local-cluster/cluster-start.sh
2023-09-23 10:03:45 +05:30

31 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Runs the specified node of the local cluster with hpcore docker image. (created via cluster-create.sh)
# This script assumes you already have the hpcore docker image and 'hpnet' virtual docker network.
# Usage (to run the node no. 1): ./cluster-start.sh 1
# Validate the node count arg.
if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then
echo "Starting docker container..."
else
echo "Error: Please provide node ID to run."
exit 1
fi
clusterloc=$(pwd)/hpcluster
n=$1
hpversion=0.6.4
let pubport=8080+$n
let peerport=22860+$n
# Mount the node<id> contract directory into hpcore docker container and run.
# We specify --network=hpnet so all nodes will communicate via 'hpnet' docker virtual network.
# We specify --name for each node so it will be the virtual dns name for each node.
docker run --rm -t -i --network=hpnet --ip=172.1.1.${n} --name=node${n} \
-p ${pubport}:${pubport} \
-p ${peerport}:${peerport} \
--device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \
--mount type=bind,source=${clusterloc}/node${n},target=/contract \
hpcore:${hpversion} run /contract