A collection of helper scripts to run gochain docker container as a local network.
-
Download and install Docker
-
goloop/gochain-icon
docker image- Build
$ git clone [email protected]:icon-project/goloop.git $ cd goloop $ make gochain-icon-image
- Verify the generated image
$ docker images goloop/gochain-icon REPOSITORY TAG IMAGE ID CREATED SIZE goloop/gochain-icon latest 74676aec69ef 2 minutes ago 513MB
- Build
You can start or stop the docker container using the following script. You can also use docker compose to start or stop the container.
$ ./run_gochain.sh
Usage: ./run_gochain.sh [start|stop|pause|unpause|ps]
$ ./run_gochain.sh start
>>> START with compose-single.yml
Creating network "gochain-local_default" with the default driver
Creating gochain-iconee ... done
$ ./run_gochain.sh ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------
gochain-iconee /entrypoint /bin/sh -c /go ... Up 8080/tcp, 9080/tcp, 0.0.0.0:9082->9082/tcp,:::9082->9082/tcp
Note that log messages will be generated at ./chain/iconee.log
.
$ head ./chain/iconee.log
I|20211008-03:27:35.242715|b6b5|-|main|main.go:433 ____ ___ ____ _ _ _ ___ _ _
I|20211008-03:27:35.243626|b6b5|-|main|main.go:433 / ___|/ _ \ / ___| | | | / \ |_ _| \ | |
I|20211008-03:27:35.243644|b6b5|-|main|main.go:433 | | _| | | | | | |_| | / _ \ | || \| |
I|20211008-03:27:35.243659|b6b5|-|main|main.go:433 | |_| | |_| | |___| _ |/ ___ \ | || |\ |
I|20211008-03:27:35.243678|b6b5|-|main|main.go:433 \____|\___/ \____|_| |_/_/ \_\___|_| \_|
I|20211008-03:27:35.243693|b6b5|-|main|main.go:435 Version : v1.0.0
I|20211008-03:27:35.243713|b6b5|-|main|main.go:436 Build : linux/amd64 tags(rocksdb)-2021-10-05-08:13:18
I|20211008-03:27:35.243732|b6b5|-|metric|metric.go:150 Initialize rootMetricCtx
T|20211008-03:27:35.244757|b6b5|-|TP|transport.go:383 registerPeerHandler &{0xc0001ca540 0xc0001ca4e0 map[] {{0 0} 0 0 0 0} 0xc0001ca5a0} true
T|20211008-03:27:35.244925|b6b5|-|TP|transport.go:383 registerPeerHandler &{0xc0001ca4b0 :8080} true
$ ./run_gochain.sh stop
>>> STOP with compose-single.yml
Stopping gochain-iconee ... done
Removing gochain-iconee ... done
Removing network gochain-local_default
$ ./run_gochain.sh pause
$ ./run_gochain.sh unpause
There are two docker Compose files as the following.
compose-single.yml
: run a single gochain node as the previous script examplecompose-multi.yml
: run multiple (four) gochain nodes which validate the same blocks
$ docker-compose -f compose-single.yml up -d
Creating network "gochain-local_default" with the default driver
Creating gochain-iconee ... done
$ docker-compose -f compose-single.yml ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------
gochain-iconee /entrypoint /bin/sh -c /go ... Up 8080/tcp, 9080/tcp, 0.0.0.0:9082->9082/tcp,:::9082->9082/tcp
$ docker-compose -f compose-multi.yml up -d
Creating network "gochain-local_default" with the default driver
Creating gochain-local_node3_1 ... done
Creating gochain-local_node0_1 ... done
Creating gochain-local_node1_1 ... done
Creating gochain-local_node2_1 ... done
$ docker-compose -f compose-multi.yml ps
Name Command State Ports
-------------------------------------------------------------------------------------------------------------------
gochain-local_node0_1 /entrypoint /bin/sh -c /go ... Up 8080/tcp, 0.0.0.0:9080->9080/tcp,:::9080->9080/tcp
gochain-local_node1_1 /entrypoint /bin/sh -c /go ... Up 8080/tcp, 0.0.0.0:9081->9080/tcp,:::9081->9080/tcp
gochain-local_node2_1 /entrypoint /bin/sh -c /go ... Up 8080/tcp, 0.0.0.0:9082->9080/tcp,:::9082->9080/tcp
gochain-local_node3_1 /entrypoint /bin/sh -c /go ... Up 8080/tcp, 0.0.0.0:9083->9080/tcp,:::9083->9080/tcp
$ docker-compose -f compose-single.yml down
or
$ docker-compose -f compose-multi.yml down
If you want to persist your data across docker restarts, set GOCHAIN_CLEAN_DATA
in ./data/single/iconee.env
to false
.
In case of the multiple nodes, modify ./data/multi/common.env
instead.
Tracker folder contains a docker-compose.yml
and .env
files to run a local blockchain explorer (a.k.a. tracker).
After starting the local gochain nodes (single or multi), run the following command to start the tracker.
$ cd tracker
$ docker-compose up -d
Creating network "tracker_default" with the default driver
Creating tracker_mysql ... done
Creating tracker_app ... done
Creating tracker_nginx ... done
Then open the page http://127.0.0.1 with your favorite web browser.