build: fix docker compose (#46)

This commit is contained in:
Thomas Nguy 2021-05-26 19:58:04 +09:00 committed by GitHub
parent 956b18f45e
commit 73dac6f5b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 21 deletions

View File

@ -5,10 +5,10 @@ services:
container_name: ethermintdnode0 container_name: ethermintdnode0
image: "ethermintd/node" image: "ethermintd/node"
ports: ports:
- "26656-26657:26656-26657" - "26657:26657"
- "1317:1317" - "1317:1317"
- "8545:8545" - "1318:1318"
- "8546:8546" - "8125:8125"
environment: environment:
- ID=0 - ID=0
- LOG=${LOG:-ethermintd.log} - LOG=${LOG:-ethermintd.log}
@ -17,16 +17,16 @@ services:
networks: networks:
localnet: localnet:
ipv4_address: 192.168.10.2 ipv4_address: 192.168.10.2
entrypoint: "bash start.sh" entrypoint: "bash start-docker.sh"
ethermintdnode1: ethermintdnode1:
container_name: ethermintdnode1 container_name: ethermintdnode1
image: "ethermintd/node" image: "ethermintd/node"
ports: ports:
- "26659-26660:26656-26657" - "26658:26657"
- "1318:1317" - "1327:1317"
- "8547:8545" - "1328:1318"
- "8548:8546" - "8126:8125"
environment: environment:
- ID=1 - ID=1
- LOG=${LOG:-ethermintd.log} - LOG=${LOG:-ethermintd.log}
@ -35,7 +35,7 @@ services:
networks: networks:
localnet: localnet:
ipv4_address: 192.168.10.3 ipv4_address: 192.168.10.3
entrypoint: "bash start.sh" entrypoint: "bash start-docker.sh"
ethermintdnode2: ethermintdnode2:
container_name: ethermintdnode2 container_name: ethermintdnode2
@ -44,16 +44,16 @@ services:
- ID=2 - ID=2
- LOG=${LOG:-ethermintd.log} - LOG=${LOG:-ethermintd.log}
ports: ports:
- "26661-26662:26656-26657" - "26659:26657"
- "1319:1317" - "1337:1317"
- "8549:8545" - "1338:1318"
- "8550:8546" - "8127:8125"
volumes: volumes:
- ./build:/ethermint:Z - ./build:/ethermint:Z
networks: networks:
localnet: localnet:
ipv4_address: 192.168.10.4 ipv4_address: 192.168.10.4
entrypoint: "bash start.sh" entrypoint: "bash start-docker.sh"
ethermintdnode3: ethermintdnode3:
container_name: ethermintdnode3 container_name: ethermintdnode3
@ -62,16 +62,16 @@ services:
- ID=3 - ID=3
- LOG=${LOG:-ethermintd.log} - LOG=${LOG:-ethermintd.log}
ports: ports:
- "26663-26664:26656-26657" - "26660:26657"
- "1320:1317" - "1347:1317"
- "8551:8545" - "1348:1318"
- "8552:8546" - "8128:8125"
volumes: volumes:
- ./build:/ethermint:Z - ./build:/ethermint:Z
networks: networks:
localnet: localnet:
ipv4_address: 192.168.10.5 ipv4_address: 192.168.10.5
entrypoint: "bash start.sh" entrypoint: "bash start-docker.sh"
networks: networks:
localnet: localnet:

View File

@ -22,8 +22,8 @@ WORKDIR /
RUN apt-get update RUN apt-get update
# Copy over binaries from the build-env # Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/cosmos/ethermint/build/ethermintd /usr/bin/ethermintd COPY --from=build-env /go/src/github.com/cosmos/ethermint/build/ethermintd /
COPY --from=build-env /go/src/github.com/cosmos/ethermint/scripts/start.sh / COPY --from=build-env /go/src/github.com/cosmos/ethermint/scripts/start-docker.sh /
EXPOSE 26656 26657 1317 8545 8546 EXPOSE 26656 26657 1317 8545 8546

29
scripts/start-docker.sh Executable file
View File

@ -0,0 +1,29 @@
#!/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
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 "started ethermint node"
tail -f /dev/null