From aef1585f95d4f7f9e1a0006e5240b8d63a3c4e65 Mon Sep 17 00:00:00 2001 From: "official-jeehong.lee@linecorp.com" Date: Wed, 18 Sep 2019 15:22:07 +0900 Subject: [PATCH] feat: Setting up test network (#41) * Setting up a test network closes issue #12 BREAKING CHANGE: makeup Build/Dockerize Commands closes issue #1 closes issue #15 closes issue #33 --- .circleci/config.yml | 5 +++-- Makefile | 15 ++++++++++----- README.md | 7 ++++--- networks/local/Makefile | 1 + networks/local/linkdnode/Dockerfile | 14 ++++++++------ networks/local/linkdnode/wrapper.sh | 2 +- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5dc6da5e4..8bd94c4cff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,8 +93,9 @@ jobs: set -x make get-tools make build-linux - make build-docker-linkdnode - make localnet-start + make build-docker-testnet + make build-conf-testnet + make start-testnet ./contrib/localnet-blocks-test.sh 40 5 10 localhost workflows: diff --git a/Makefile b/Makefile index 81a95f1516..3ca32d5aab 100644 --- a/Makefile +++ b/Makefile @@ -157,16 +157,21 @@ benchmark: ######################################## ### Local validator nodes using docker and docker-compose -build-docker-linkdnode: - $(MAKE) -C networks/local +build-docker-testnet: + $(MAKE) -C $(CURDIR)/networks/local + +build-conf-testnet: + rm -rf $(CURDIR)/build/gentxs + rm -rf $(CURDIR)/build/node* + docker run --rm -v $(CURDIR)/build:/linkd:Z line/linkdnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 + # Run a 4-node testnet locally -localnet-start: localnet-stop - @if ! [ -f build/node0/linkd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/linkd:Z line/linkdnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi +start-testnet: stop-testnet docker-compose up -d # Stop testnet -localnet-stop: +stop-testnet: docker-compose down ######################################## diff --git a/README.md b/README.md index 9363df4ab6..005c219b27 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,10 @@ make check-build # integration test (/cli_test) ### Test Net ``` make build-linux # Cross-compile the binaries for linux/amd64 -make build-docker-linkdnode # Build docker image for local test -make localnet-start # Boot up local test network with 4 validator nodes -make localnet-stop # Stop the network +make build-docker-testnet # Build docker image for testnet +make build-conf-testnet # Build configurations for testnet +make start-testnet # Boot up testnet network with 4 validator nodes +make stop-testnet # Stop the testnet ``` diff --git a/networks/local/Makefile b/networks/local/Makefile index 994d2da8ea..3153504176 100644 --- a/networks/local/Makefile +++ b/networks/local/Makefile @@ -1,6 +1,7 @@ # Makefile for the "linkdnode" docker image. all: + docker rmi -f line/linkdnode docker build --tag line/linkdnode linkdnode .PHONY: all diff --git a/networks/local/linkdnode/Dockerfile b/networks/local/linkdnode/Dockerfile index e1ae76b105..05dc009e3c 100644 --- a/networks/local/linkdnode/Dockerfile +++ b/networks/local/linkdnode/Dockerfile @@ -1,16 +1,18 @@ FROM alpine:3.7 -MAINTAINER Greg Szabo +MAINTAINER LinkChain RUN apk update && \ apk upgrade && \ - apk --no-cache add curl jq file + apk add --update --no-cache autoconf bash jq file curl git lsof wget iputils vim busybox-extras -VOLUME [ /linkd ] +ENV LINKCLIHOME /linkd +ENV PATH="$PATH:$LINKCLIHOME" + +STOPSIGNAL SIGTERM +COPY wrapper.sh /usr/bin/wrapper.sh WORKDIR /linkd + EXPOSE 26656 26657 ENTRYPOINT ["/usr/bin/wrapper.sh"] CMD ["start"] -STOPSIGNAL SIGTERM - -COPY wrapper.sh /usr/bin/wrapper.sh diff --git a/networks/local/linkdnode/wrapper.sh b/networks/local/linkdnode/wrapper.sh index eb23117cd0..efe2e196a7 100755 --- a/networks/local/linkdnode/wrapper.sh +++ b/networks/local/linkdnode/wrapper.sh @@ -23,7 +23,7 @@ fi ## ## Run binary with all parameters ## -export LINKDHOME="/linkd/node${ID}/linkd" +export LINKDHOME="${LINKDHOME:-/linkd/node${ID}/linkd}" if [ -d "`dirname ${LINKDHOME}/${LOG}`" ]; then "$BINARY" --home "$LINKDHOME" "$@" | tee "${LINKDHOME}/${LOG}"