From 76bf5a3c5d5063137010860711e1796da516efa3 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Thu, 13 Apr 2023 18:09:37 +0530 Subject: [PATCH] Use mounted volumes for data in geth nodes --- app/data/compose/docker-compose-fixturenet-eth.yml | 8 ++++++++ .../container-build/cerc-fixturenet-eth-geth/Dockerfile | 2 +- .../genesis/accounts/import_keys.sh | 2 +- .../container-build/cerc-fixturenet-eth-geth/run-el.sh | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/data/compose/docker-compose-fixturenet-eth.yml b/app/data/compose/docker-compose-fixturenet-eth.yml index 508543e4..238ca38e 100644 --- a/app/data/compose/docker-compose-fixturenet-eth.yml +++ b/app/data/compose/docker-compose-fixturenet-eth.yml @@ -8,6 +8,8 @@ services: environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-geth:local + volumes: + - bootnode_geth_data:/root/ethdata ports: - "9898" - "30303" @@ -26,6 +28,7 @@ services: image: cerc/fixturenet-eth-geth:local volumes: - fixturenet_geth_accounts:/opt/testnet/build/el + - fixturenet_eth_geth_1_data:/root/ethdata healthcheck: test: ["CMD", "nc", "-v", "localhost", "8545"] interval: 30s @@ -52,6 +55,8 @@ services: image: cerc/fixturenet-eth-geth:local depends_on: - fixturenet-eth-bootnode-geth + volumes: + - fixturenet_eth_geth_2_data:/root/ethdata fixturenet-eth-bootnode-lighthouse: hostname: fixturenet-eth-bootnode-lighthouse @@ -106,3 +111,6 @@ services: volumes: fixturenet_geth_accounts: + bootnode_geth_data: + fixturenet_eth_geth_1_data: + fixturenet_eth_geth_2_data: diff --git a/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile b/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile index 51dbbcd4..63c3c0a7 100644 --- a/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile +++ b/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile @@ -22,6 +22,6 @@ COPY run-el.sh /opt/testnet/run.sh RUN cd /opt/testnet && make genesis-el COPY --from=geth /usr/local/bin/geth /usr/local/bin/ -RUN geth init /opt/testnet/build/el/geth.json && rm -f ~/.ethereum/geth/nodekey +RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey ENTRYPOINT ["/opt/testnet/run.sh"] diff --git a/app/data/container-build/cerc-fixturenet-eth-geth/genesis/accounts/import_keys.sh b/app/data/container-build/cerc-fixturenet-eth-geth/genesis/accounts/import_keys.sh index 719b9f59..e8dce0ea 100755 --- a/app/data/container-build/cerc-fixturenet-eth-geth/genesis/accounts/import_keys.sh +++ b/app/data/container-build/cerc-fixturenet-eth-geth/genesis/accounts/import_keys.sh @@ -12,6 +12,6 @@ for line in `cat ../build/el/accounts.csv`; do echo "" echo "$ADDRESS" - geth account import --password .pw.$$ .key.$$ + geth account import --datadir=~/ethdata --password .pw.$$ .key.$$ rm -f .pw.$$ .key.$$ done diff --git a/app/data/container-build/cerc-fixturenet-eth-geth/run-el.sh b/app/data/container-build/cerc-fixturenet-eth-geth/run-el.sh index 12e59462..eca702e4 100755 --- a/app/data/container-build/cerc-fixturenet-eth-geth/run-el.sh +++ b/app/data/container-build/cerc-fixturenet-eth-geth/run-el.sh @@ -13,7 +13,7 @@ cd /opt/testnet/build/el python3 -m http.server 9898 & cd $HOME_DIR -START_CMD="geth" +START_CMD="geth --datadir=~/ethdata" if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --" fi @@ -28,7 +28,7 @@ if [ "true" == "$RUN_BOOTNODE" ]; then else cd /opt/testnet/accounts ./import_keys.sh - + echo -n "$JWT" > /opt/testnet/build/el/jwtsecret if [ "$CERC_RUN_STATEDIFF" == "detect" ] && [ -n "$CERC_STATEDIFF_DB_HOST" ]; then