Skip to content

Commit

Permalink
build: fix build environment for the liveness test (backport cosmos#1…
Browse files Browse the repository at this point in the history
…0551) (cosmos#10552)

* build: fix build environment for the liveness test (cosmos#10551)

Extracted from cosmos#10210.

Make the test more reproducible, so that it does not require coordination
between the build container and the run container.

- Use layers to more advantage.
- Include bash in the run container.
- Put writable output onto a volume.

(cherry picked from commit 70a3a90)

* fix conflict

Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
  • Loading branch information
3 people authored and Eengineer1 committed Aug 25, 2022
1 parent 5b920db commit d675ad6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 57 deletions.
9 changes: 2 additions & 7 deletions Makefile
Expand Up @@ -483,13 +483,8 @@ proto-update-deps:
# Run a 4-node testnet locally
localnet-start: build-linux localnet-stop
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
if ! [ -f build/node0/simd/config/genesis.json ]; then $(DOCKER) run --rm \
--user $(shell id -u):$(shell id -g) \
-v $(BUILDDIR):/simd:Z \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
cosmossdk/simd-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
$(DOCKER) run --rm -v $(CURDIR)/localnet:/data cosmossdk/simd-env \
testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test
docker-compose up -d

localnet-stop:
Expand Down
15 changes: 4 additions & 11 deletions contrib/images/Makefile
@@ -1,14 +1,7 @@
all: simd-env

simd-env: simd-rmi
docker build --tag cosmossdk/simd -f simd-env/Dockerfile \
$(shell git rev-parse --show-toplevel)
simd-env:
docker build --tag cosmossdk/simd-env -f simd-env/Dockerfile \
$(shell git rev-parse --show-toplevel)

simd-dlv: simd-rmi
docker build --tag cosmossdk/simd -f simd-dlv/Dockerfile \
$(shell git rev-parse --show-toplevel)

simd-rmi:
docker rmi cosmossdk/simd 2>/dev/null; true

.PHONY: all simd-env simd-dlv simd-rmi
.PHONY: all simd-env
54 changes: 15 additions & 39 deletions docker-compose.yml
Expand Up @@ -3,88 +3,64 @@ version: "3"
services:
simdnode0:
container_name: simdnode0
image: "cosmossdk/simd"
environment:
- DEBUG=1
- ID=0
- LOG=${LOG:-simd.log}
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
image: "cosmossdk/simd-env"
ports:
- "26656-26657:26656-26657"
- "1317:1317"
- "9090:9090"
- "2345:2345"
environment:
- ID=0
- LOG=${LOG:-simd.log}
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.2

simdnode1:
container_name: simdnode1
image: "cosmossdk/simd"
environment:
- DEBUG=0
- ID=1
- LOG=${LOG:-simd.log}
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
image: "cosmossdk/simd-env"
ports:
- "26666-26667:26656-26657"
- "1318:1317"
- "9091:9090"
- "2346:2345"
environment:
- ID=1
- LOG=${LOG:-simd.log}
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.3

simdnode2:
container_name: simdnode2
image: "cosmossdk/simd"
image: "cosmossdk/simd-env"
environment:
- DEBUG=0
- ID=2
- LOG=${LOG:-simd.log}
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
ports:
- "26676-26677:26656-26657"
- "1319:1317"
- "9092:9090"
- "2347:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.4

simdnode3:
container_name: simdnode3
image: "cosmossdk/simd"
image: "cosmossdk/simd-env"
environment:
- DEBUG=0
- ID=3
- LOG=${LOG:-simd.log}
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
ports:
- "26686-26687:26656-26657"
- "1320:1317"
- "9093:9090"
- "2348:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.5
Expand All @@ -95,4 +71,4 @@ networks:
ipam:
driver: default
config:
- subnet: 192.168.10.0/25
- subnet: 192.168.10.0/16

0 comments on commit d675ad6

Please sign in to comment.