Skip to content

Commit

Permalink
refactor: more docker compose deduplicating
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jul 2, 2024
1 parent 8982129 commit d5aea2f
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 155 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]
FROM golang:1.20.14-bookworm AS base-runtime

RUN apt update && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \
rm -rf /var/lib/apt/lists/*

RUN ssh-keygen -A && \
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ start-localnet-skip-build:
export LOCALNET_MODE=setup-only && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d

# stop-localnet should include all profiles so other containers are also removed
stop-localnet:
cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans
cd contrib/localnet/ && $(DOCKER) compose --profile eth2 --profile stress --profile upgrade down --remove-orphans

###############################################################################
### E2E tests ###
Expand All @@ -240,7 +241,7 @@ start-e2e-test: zetanode
start-e2e-admin-test: zetanode
@echo "--> Starting e2e admin test"
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-additionalevm.yml up -d
cd contrib/localnet/ && $(DOCKER) compose --profile eth2 -f docker-compose.yml up -d

start-e2e-performance-test: zetanode
@echo "--> Starting e2e performance test"
Expand All @@ -255,7 +256,7 @@ start-e2e-import-mainnet-test: zetanode

start-stress-test: zetanode
@echo "--> Starting stress test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stress.yml up -d
cd contrib/localnet/ && $(DOCKER) compose --profile stress -f docker-compose.yml up -d

###############################################################################
### Upgrade Tests ###
Expand All @@ -272,21 +273,22 @@ start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=225 && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-import-mainnet-test: zetanode-upgrade
@echo "--> Starting import-data upgrade test"
export LOCALNET_MODE=upgrade && \
export ZETACORED_IMPORT_GENESIS_DATA=true && \
export ZETACORED_START_PERIOD=15m && \
export UPGRADE_HEIGHT=225 && \
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d

###############################################################################
### Monitoring ###
###############################################################################
Expand Down
24 changes: 0 additions & 24 deletions contrib/localnet/docker-compose-additionalevm.yml

This file was deleted.

73 changes: 0 additions & 73 deletions contrib/localnet/docker-compose-stress.yml

This file was deleted.

43 changes: 12 additions & 31 deletions contrib/localnet/docker-compose-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: "3"
# This docker-compose redefine the services:
# - ZetaChain with 2 nodes (zetacore0, zetacore1) using the upgrade option for cosmovisor
# - ZetaChain observer set with 2 clients (zetaclient0, zetaclient1) using the background option
# - Orchestrator with upgrade option
# This docker-compose updates the services to use the old version of the zetanode image

services:
zetacore0:
Expand All @@ -11,36 +8,20 @@ services:
zetacore1:
image: zetanode:old

zetacore2:
image: zetanode:old

zetacore3:
image: zetanode:old

zetaclient0:
image: zetanode:old

zetaclient1:
image: zetanode:old

upgrade-host:
image: zetanode:latest
container_name: upgrade-host
hostname: upgrade-host
entrypoint: ["/root/start-upgrade-host.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.250
volumes:
- ssh:/root/.ssh

upgrade-orchestrator:
# must run from old node for api compatibility
image: zetanode:old
container_name: upgrade-orchestrator
hostname: upgrade-orchestrator
entrypoint: ["/root/start-upgrade-orchestrator.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.251
depends_on:
- zetacore0
- upgrade-host
environment:
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh
zetaclient2:
image: zetanode:old

zetaclient3:
image: zetanode:old
121 changes: 117 additions & 4 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# This docker-compose file configures the localnet environment
# it contains the following services:
# - ZetaChain with 2 nodes (zetacore0, zetacore1)
# - A observer set with 2 clients (zetaclient0, zetaclient1)
# - ZetaChain with 2 nodes (zetacore0, zetacore1). When profile set to stress, 4 nodes will be created.
# - A observer set with 2 clients (zetaclient0, zetaclient1). When profile set to stress, 4 clients will be created.
# - An Ethereum node (eth)
# - A secondary optional Ethereum node (eth2) enabled when profile is set to eth2
# - A Bitcoin node (bitcoin)
# - A Rosetta API (rosetta)
# - An orchestrator to manage interaction with the localnet (orchestrator)
# - An upgrade host to serve binaries for the upgrade tests (upgrade-host). Only enabled when profile is set to upgrade.
# - An upgrade orchestrator to send the upgrade governance proposal (upgrade-orchestrator). Only enabled when profile is set to upgrade.

networks:
mynetwork:
Expand Down Expand Up @@ -56,7 +59,6 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=2
- ZETACORED_IMPORT_GENESIS_DATA=${ZETACORED_IMPORT_GENESIS_DATA}
volumes:
- ssh:/root/.ssh
Expand All @@ -73,7 +75,38 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=2
volumes:
- ssh:/root/.ssh

zetacore2:
image: zetanode:latest
container_name: zetacore2
hostname: zetacore2
profiles:
- stress
networks:
mynetwork:
ipv4_address: 172.20.0.13
entrypoint: [ "/root/start-zetacored.sh", "4" ]
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh

zetacore3:
image: zetanode:latest
container_name: zetacore3
hostname: zetacore3
profiles:
- stress
networks:
mynetwork:
ipv4_address: 172.20.0.14
entrypoint: [ "/root/start-zetacored.sh", "4" ]
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh

Expand Down Expand Up @@ -109,6 +142,40 @@ services:
- ssh:/root/.ssh
- preparams:/root/preparams

zetaclient2:
image: zetanode:latest
container_name: zetaclient2
hostname: zetaclient2
profiles:
- stress
networks:
mynetwork:
ipv4_address: 172.20.0.23
entrypoint: /root/start-zetaclientd.sh
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

zetaclient3:
image: zetanode:latest
container_name: zetaclient3
hostname: zetaclient3
profiles:
- stress
networks:
mynetwork:
ipv4_address: 172.20.0.24
entrypoint: /root/start-zetaclientd.sh
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

eth:
image: ethereum/client-go:v1.10.26
container_name: eth
Expand All @@ -120,6 +187,20 @@ services:
ipv4_address: 172.20.0.100
entrypoint: ["geth", "--dev", "--http", "--http.addr", "172.20.0.100", "--http.vhosts", "*", "--http.api", "eth,web3,net", "--http.corsdomain", "https://remix.ethereum.org", "--dev.period", "2"]

eth2:
build:
context: ./anvil
container_name: eth2
hostname: eth2
profiles:
- eth2
platform: linux/amd64
ports:
- "8546:8545"
networks:
mynetwork:
ipv4_address: 172.20.0.102

bitcoin:
image: ruimarinho/bitcoin-core:22 # version 23 is not working with btcd 0.22.0 due to change in createwallet rpc
container_name: bitcoin
Expand Down Expand Up @@ -157,6 +238,38 @@ services:
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh

upgrade-host:
image: zetanode:latest
container_name: upgrade-host
hostname: upgrade-host
profiles:
- upgrade
entrypoint: ["/root/start-upgrade-host.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.250
volumes:
- ssh:/root/.ssh

upgrade-orchestrator:
# must run from old node for api compatibility
image: zetanode:old
container_name: upgrade-orchestrator
hostname: upgrade-orchestrator
profiles:
- upgrade
entrypoint: ["/root/start-upgrade-orchestrator.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.251
depends_on:
- zetacore0
- upgrade-host
environment:
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh
volumes:
ssh:
preparams:
Loading

0 comments on commit d5aea2f

Please sign in to comment.