From 121c5b0f27713a156a3001e6d63b60448b6b4f56 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Jan 2024 16:06:32 +0700 Subject: [PATCH] feat: setup cosmosvisor to run migalood --- contrib/migalood-env/Dockerfile | 5 +- contrib/migalood-env/Makefile | 2 +- contrib/updates/docker-compose.yml | 68 +++++++++++++++++++++++++++ contrib/updates/prepare_cosmovisor.sh | 40 ++++++++-------- 4 files changed, 90 insertions(+), 25 deletions(-) create mode 100644 contrib/updates/docker-compose.yml diff --git a/contrib/migalood-env/Dockerfile b/contrib/migalood-env/Dockerfile index 83be4eb2..018dc558 100644 --- a/contrib/migalood-env/Dockerfile +++ b/contrib/migalood-env/Dockerfile @@ -4,16 +4,13 @@ RUN apt-get update && \ apt-get -y upgrade && \ apt-get -y install curl jq file -ARG UID=1000 -ARG GID=1000 ARG entrypoint=entrypoint.sh -USER ${UID}:${GID} VOLUME /migalood WORKDIR /migalood EXPOSE 26656 26657 ENTRYPOINT ["/usr/bin/entrypoint.sh"] -CMD ["start", "--log_format", "plain"] +CMD ["start", "--log_format", "plain", "--p2p.seeds", ""] STOPSIGNAL SIGTERM COPY ${entrypoint} /usr/bin/entrypoint.sh diff --git a/contrib/migalood-env/Makefile b/contrib/migalood-env/Makefile index 0377b717..d7da0843 100644 --- a/contrib/migalood-env/Makefile +++ b/contrib/migalood-env/Makefile @@ -1,6 +1,6 @@ all: migalood-upgrade-env migalood-upgrade-env: - docker build --platform linux/amd64 --no-cache --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --build-arg entrypoint=cosmovisor-entrypoint.sh --tag migaloo/migalood-upgrade-env . + docker build --platform linux/amd64 --no-cache --build-arg entrypoint=cosmovisor-entrypoint.sh --tag migaloo/migalood-upgrade-env . .PHONY: all migalood-upgrade-env diff --git a/contrib/updates/docker-compose.yml b/contrib/updates/docker-compose.yml new file mode 100644 index 00000000..c069cf0e --- /dev/null +++ b/contrib/updates/docker-compose.yml @@ -0,0 +1,68 @@ +version: '3' + +services: + migaloodnode0: + container_name: migaloodnode0 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + ports: + - "9090:9090" + - "26656-26657:26656-26657" + environment: + - ID=0 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node0/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.2 + + migaloodnode1: + container_name: migaloodnode1 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + ports: + - "9091:9090" + - "26659-26660:26656-26657" + environment: + - ID=1 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node1/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.3 + + migaloodnode2: + container_name: migaloodnode2 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + environment: + - ID=2 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node2/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + ports: + - "9092:9090" + - "26661-26662:26656-26657" + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.4 + +networks: + localnet: + driver: bridge + ipam: + driver: default + config: + - + subnet: 192.168.10.0/16 \ No newline at end of file diff --git a/contrib/updates/prepare_cosmovisor.sh b/contrib/updates/prepare_cosmovisor.sh index 4216dce9..59698636 100755 --- a/contrib/updates/prepare_cosmovisor.sh +++ b/contrib/updates/prepare_cosmovisor.sh @@ -18,44 +18,44 @@ if [ -z "$BUILDDIR" ]; then exit 1 fi -# # install old binary if not exist -# if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null -# then -# mkdir -p _build/old -# wget -c "https://github.com/White-Whale-Defi-Platform/migaloo-chain/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip -# unzip _build/${OLD_VERSION}.zip -d _build -# fi +# install old binary if not exist +if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null +then + mkdir -p _build/old + wget -c "https://github.com/White-Whale-Defi-Platform/migaloo-chain/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip + unzip _build/${OLD_VERSION}.zip -d _build +fi -# if [ ! -f "$BUILDDIR/$OLD_VERSION.zip" ] &> /dev/null -# then -# mkdir -p BUILDDIR/old -# # docker build --platform linux/amd64 --no-cache --build-arg source=./_build/migaloo-chain-${OLD_VERSION:1}/ --tag migaloo/migalood.binary.old . -# docker create --platform linux/amd64 --name old-temp migaloo/migalood.binary.old:latest -# mkdir -p $BUILDDIR/old -# docker cp old-temp:/usr/bin/migalood $BUILDDIR/old/ -# docker rm old-temp -# fi +if [ ! -f "$BUILDDIR/$OLD_VERSION.zip" ] &> /dev/null +then + mkdir -p BUILDDIR/old + # docker build --platform linux/amd64 --no-cache --build-arg source=./_build/migaloo-chain-${OLD_VERSION:1}/ --tag migaloo/migalood.binary.old . + docker create --platform linux/amd64 --name old-temp migaloo/migalood.binary.old:latest + mkdir -p $BUILDDIR/old + docker cp old-temp:/usr/bin/migalood $BUILDDIR/old/ + docker rm old-temp +fi # prepare cosmovisor config in TESTNET_NVAL nodes -if [ ! -f "$BUILDDIR/node0/simd/config/genesis.json" ]; then docker run --rm \ +if [ ! -f "$BUILDDIR/node0/migalood/config/genesis.json" ]; then docker run --rm \ -v $BUILDDIR:/migalood:Z \ --platform linux/amd64 \ --entrypoint /migalood/old/migalood \ - migaloo/migalood-upgrade-env testnet init-files --v $TESTNET_NVAL --chain-id $TESTNET_CHAINID -o . --starting-ip-address 192.168.10.2 --keyring-backend=test --home=temp; \ + migaloo/migalood-upgrade-env testnet init-files --v $TESTNET_NVAL --chain-id $TESTNET_CHAINID -o . --starting-ip-address 192.168.10.2 --node-daemon-home migalood --keyring-backend=test --home=temp; \ fi for (( i=0; i<$TESTNET_NVAL; i++ )); do - CURRENT=$BUILDDIR/node$i/simd + CURRENT=$BUILDDIR/node$i/migalood # change gov params voting_period jq '.app_state.gov.voting_params.voting_period = "50s"' $CURRENT/config/genesis.json > $CURRENT/config/genesis.json.tmp && mv $CURRENT/config/genesis.json.tmp $CURRENT/config/genesis.json docker run --rm \ -v $BUILDDIR:/migalood:Z \ - -e DAEMON_HOME=/migalood/node$i/simd \ + -e DAEMON_HOME=/migalood/node$i/migalood \ -e DAEMON_NAME=migalood \ -e DAEMON_RESTART_AFTER_UPGRADE=true \ --entrypoint /migalood/cosmovisor \