diff --git a/Makefile b/Makefile index 60a81fe35..ce3b9ed56 100755 --- a/Makefile +++ b/Makefile @@ -193,6 +193,10 @@ build-docker: build-linux: GOOS=linux GOARCH=amd64 $(MAKE) build +build-docker-localnode: + cd networks/local + make + # Run a 4-node testnet locally localnet-start: localnet-stop @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2 ; fi diff --git a/docs/using-tendermint.rst b/docs/using-tendermint.rst index f572277cd..56790feae 100644 --- a/docs/using-tendermint.rst +++ b/docs/using-tendermint.rst @@ -28,8 +28,11 @@ genesis file (``genesis.json``) containing the associated public key, in ``$TMHOME/config``. This is all that's necessary to run a local testnet with one validator. -For more elaborate initialization, see our `testnet deployment -tool `__. +For more elaborate initialization, see the `tesnet` command: + +:: + + tendermint testnet --help Run --- diff --git a/networks/local/README.rst b/networks/local/README.rst index d22a24d9b..601d238de 100644 --- a/networks/local/README.rst +++ b/networks/local/README.rst @@ -1,29 +1,79 @@ localnode ========= -It is assumed that you have already `setup docker `__. +Requirements +------------ -Description +- `Install docker `__. +- `Install docker-compose `__. + +Build +----- + +Build the `tendermint` binary and the `tendermint/localnode` docker image: + +``` +cd $GOPATH/src/github.com/tendermint/tendermint + +# Install dependencies (skip if already done) +make get_tools +make get_vendor_deps + +# Build binary in ./build +make build-linux + +# Build tendermint/localnode image +make build-docker-localnode + +``` + +Run a testnet +------------- + +To start a 4 node testnet run: + +``` +make localnet-start + +`` + +The nodes bind their RPC servers to ports 46657, 46660, 46662, and 46664 on the host. +This file creates a 4-node network using the localnode image. +The nodes of the network expose their P2P and RPC endpoints to the host machine on ports 46656-46657, 46659-46660, 46661-46662, and 46663-46664 respectively. + +To update the binary, just rebuild it and restart the nodes: + +``` +make build-linux +make localnet-stop +make localnet-start + +``` + +Configuration ----------- -Image for local testnets. -Add the tendermint binary to the image by attaching it in a folder to the `/tendermint` mount point. +The `make localnet-start` creates files for a 4-node testnet in `./build` by calling the `tendermint testnet` command. + +The `./build` directory is mounted to the `/tendermint` mount point to attach the binary and config files to the container. -It assumes that the configuration was created by the `tendermint testnet` command and it is also attached to the `/tendermint` mount point. +For instance, to create a single node testnet: -Example: -This example builds a linux tendermint binary under the `build/` folder, creates tendermint configuration for a single-node validator and runs the node: ``` cd $GOPATH/src/github.com/tendermint/tendermint -#Build binary +# Clear the build folder +rm -rf ./build + +# Build binary make build-linux -#Create configuration +# Create configuration docker run -e LOG="stdout" -v `pwd`/build:/tendermint tendermint/localnode testnet --o . --v 1 #Run the node docker run -v `pwd`/build:/tendermint tendermint/localnode + ``` Logging @@ -34,7 +84,3 @@ Special binaries ---------------- If you have multiple binaries with different names, you can specify which one to run with the BINARY environment variable. The path of the binary is relative to the attached volume. -docker-compose.yml -================== -This file creates a 4-node network using the localnode image. The nodes of the network are exposed to the host machine on ports 46656-46657, 46659-46660, 46661-46662, 46663-46664 respectively. -