build: fix docker setup (#337)
* fix: issue #310 - add ip-addresses for localnet-setup generation - add localnet-setup folder to keep localnet-setup-artifacts - map localnet-setup-artifacts to containers - change start-docker.sh to pick up generated testnet artifacts * feat: get rid of explicit ip-address-assignments for containers * feat: get rid of docker-localnet, introduce localnet-build and localnet-show-logstream, fix localnet-unsafe-reset and localnet-clean, add comments * fix: add --no-cache on docker build, exclude build-directory
This commit is contained in:
parent
396db9f20a
commit
300af0df0e
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
# localnet-setup
|
||||
localnet-setup
|
||||
|
||||
# build
|
||||
build
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -36,6 +36,9 @@ keyring_test_cosmos
|
||||
secret.yml
|
||||
# vue/
|
||||
|
||||
# Local docker volume mappings
|
||||
localnet-setup
|
||||
|
||||
# Testing
|
||||
coverage.txt
|
||||
*.out
|
||||
|
@ -21,7 +21,7 @@ FROM alpine
|
||||
|
||||
# Install ca-certificates
|
||||
RUN apk add --update ca-certificates jq
|
||||
WORKDIR /root
|
||||
WORKDIR /
|
||||
|
||||
# Copy over binaries from the build-env
|
||||
COPY --from=build-env /go/src/github.com/tharsis/ethermint/build/ethermintd /usr/bin/ethermintd
|
||||
|
48
Makefile
48
Makefile
@ -131,9 +131,6 @@ docker-build:
|
||||
mkdir -p ./build/
|
||||
docker cp ethermint:/usr/bin/ethermintd ./build/
|
||||
|
||||
docker-localnet:
|
||||
docker build -f ./networks/local/ethermintnode/Dockerfile . -t ethermintd/node
|
||||
|
||||
$(MOCKS_DIR):
|
||||
mkdir -p $(MOCKS_DIR)
|
||||
|
||||
@ -477,49 +474,54 @@ proto-update-deps:
|
||||
### Localnet ###
|
||||
###############################################################################
|
||||
|
||||
# Run a 4-node testnet locally
|
||||
build-docker-local-ethermint:
|
||||
# Build image for a local testnet
|
||||
localnet-build:
|
||||
@$(MAKE) -C networks/local
|
||||
|
||||
# Run a 4-node testnet locally
|
||||
# Start a 4-node testnet locally
|
||||
localnet-start: localnet-stop
|
||||
ifeq ($(OS),Windows_NT)
|
||||
mkdir build &
|
||||
@$(MAKE) docker-localnet
|
||||
mkdir localnet-setup &
|
||||
@$(MAKE) localnet-build
|
||||
|
||||
IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --keyring-backend=test"
|
||||
IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"
|
||||
docker-compose up -d
|
||||
else
|
||||
mkdir -p ./build/
|
||||
@$(MAKE) docker-localnet
|
||||
mkdir -p localnet-setup
|
||||
@$(MAKE) localnet-build
|
||||
|
||||
if ! [ -f build/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd testnet --v 4 -o /ethermint --keyring-backend=test"; fi
|
||||
if ! [ -f localnet-setup/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/localnet-setup:/ethermint:Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"; fi
|
||||
docker-compose up -d
|
||||
endif
|
||||
|
||||
# Stop testnet
|
||||
localnet-stop:
|
||||
docker-compose down
|
||||
|
||||
# clean testnet
|
||||
# Clean testnet
|
||||
localnet-clean:
|
||||
docker-compose down
|
||||
sudo rm -rf build/*
|
||||
sudo rm -rf localnet-setup
|
||||
|
||||
# reset testnet
|
||||
# Reset testnet
|
||||
localnet-unsafe-reset:
|
||||
docker-compose down
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node0/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node1/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node2/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node3/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)\localnet-setup\node0\ethermitd:ethermint\Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)\localnet-setup\node1\ethermitd:ethermint\Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)\localnet-setup\node2\ethermitd:ethermint\Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)\localnet-setup\node3\ethermitd:ethermint\Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
else
|
||||
@docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node0/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node1/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node2/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "ethermintd unsafe-reset-all --home=/ethermint/node3/ethermintd"
|
||||
@docker run --rm -v $(CURDIR)/localnet-setup/node0/ethermitd:/ethermint:Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)/localnet-setup/node1/ethermitd:/ethermint:Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)/localnet-setup/node2/ethermitd:/ethermint:Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
@docker run --rm -v $(CURDIR)/localnet-setup/node3/ethermitd:/ethermint:Z ethermintd/node "./ethermintd unsafe-reset-all --home=/ethermint"
|
||||
endif
|
||||
|
||||
# Clean testnet
|
||||
localnet-show-logstream:
|
||||
docker-compose logs --tail=1000 -f
|
||||
|
||||
.PHONY: build-docker-local-ethermint localnet-start localnet-stop
|
||||
|
||||
# release
|
||||
|
@ -13,10 +13,9 @@ services:
|
||||
- ID=0
|
||||
- LOG=${LOG:-ethermintd.log}
|
||||
volumes:
|
||||
- ./build:/ethermint:Z
|
||||
- ./localnet-setup/node0/ethermintd:/ethermint:Z
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 192.168.10.2
|
||||
- localnet
|
||||
entrypoint: "bash start-docker.sh"
|
||||
|
||||
ethermintdnode1:
|
||||
@ -31,10 +30,9 @@ services:
|
||||
- ID=1
|
||||
- LOG=${LOG:-ethermintd.log}
|
||||
volumes:
|
||||
- ./build:/ethermint:Z
|
||||
- ./localnet-setup/node1/ethermintd:/ethermint:Z
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 192.168.10.3
|
||||
- localnet
|
||||
entrypoint: "bash start-docker.sh"
|
||||
|
||||
ethermintdnode2:
|
||||
@ -49,10 +47,9 @@ services:
|
||||
- "8566:8546"
|
||||
- "8127:8125"
|
||||
volumes:
|
||||
- ./build:/ethermint:Z
|
||||
- ./localnet-setup/node2/ethermintd:/ethermint:Z
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 192.168.10.4
|
||||
- localnet
|
||||
entrypoint: "bash start-docker.sh"
|
||||
|
||||
ethermintdnode3:
|
||||
@ -67,16 +64,10 @@ services:
|
||||
- "8576:8546"
|
||||
- "8128:8125"
|
||||
volumes:
|
||||
- ./build:/ethermint:Z
|
||||
- ./localnet-setup/node3/ethermintd:/ethermint:Z
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 192.168.10.5
|
||||
- localnet
|
||||
entrypoint: "bash start-docker.sh"
|
||||
|
||||
networks:
|
||||
localnet:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 192.168.10.0/16
|
||||
|
@ -1,4 +1,4 @@
|
||||
all:
|
||||
docker build --tag ethermintd/node ethermintnode
|
||||
docker build --no-cache --tag ethermintd/node ../.. -f ethermintnode/Dockerfile
|
||||
|
||||
.PHONY: all
|
||||
|
@ -12,7 +12,7 @@ WORKDIR /go/src/github.com/tharsis/ethermint
|
||||
COPY . .
|
||||
|
||||
# build Ethermint
|
||||
RUN make build-ethermint-linux
|
||||
RUN make build-linux
|
||||
|
||||
# Final image
|
||||
FROM golang:1.14 as final
|
||||
|
@ -1,29 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
KEY="mykey"
|
||||
CHAINID="ethermint-123"
|
||||
MONIKER="mymoniker"
|
||||
DATA_DIR=$(mktemp -d -t ethermint-datadir.XXXXX)
|
||||
|
||||
echo "create and add new keys"
|
||||
./ethermintd keys add $KEY --home $DATA_DIR --no-backup --chain-id $CHAINID --algo "eth_secp256k1" --keyring-backend test
|
||||
echo "init Ethermint with moniker=$MONIKER and chain-id=$CHAINID"
|
||||
./ethermintd init $MONIKER --chain-id $CHAINID --home $DATA_DIR
|
||||
echo "prepare genesis: Allocate genesis accounts"
|
||||
./ethermintd add-genesis-account \
|
||||
"$(./ethermintd keys show $KEY -a --home $DATA_DIR --keyring-backend test)" 1000000000000000000aphoton,1000000000000000000stake \
|
||||
--home $DATA_DIR --keyring-backend test
|
||||
echo "prepare genesis: Sign genesis transaction"
|
||||
./ethermintd gentx $KEY 1000000000000000000stake --keyring-backend test --home $DATA_DIR --keyring-backend test --chain-id $CHAINID
|
||||
echo "prepare genesis: Collect genesis tx"
|
||||
./ethermintd collect-gentxs --home $DATA_DIR
|
||||
echo "prepare genesis: Run validate-genesis to ensure everything worked and that the genesis file is setup correctly"
|
||||
./ethermintd validate-genesis --home $DATA_DIR
|
||||
./ethermintd validate-genesis --home /ethermint
|
||||
|
||||
echo "starting ethermint node $i in background ..."
|
||||
./ethermintd start --pruning=nothing --rpc.unsafe \
|
||||
--keyring-backend test --home $DATA_DIR \
|
||||
>$DATA_DIR/node.log 2>&1 & disown
|
||||
echo "starting ethermint node $ID in background ..."
|
||||
./ethermintd start \
|
||||
--home /ethermint \
|
||||
--keyring-backend test
|
||||
|
||||
echo "started ethermint node"
|
||||
tail -f /dev/null
|
Loading…
Reference in New Issue
Block a user