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)

# Conflicts:
#	Makefile

* fix conflict

Co-authored-by: M. J. Fromberger <[email protected]>
Co-authored-by: Robert Zaremba <[email protected]>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 9360903 commit 0742e86
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ jobs:

test-x-accounts-base:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,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
4 changes: 2 additions & 2 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: simd-env

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

simd-dlv: simd-rmi
Expand Down
46 changes: 9 additions & 37 deletions contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,21 @@
FROM golang:1.23-alpine AS build

FROM golang:1.17-alpine AS build
RUN apk add build-base git linux-headers

WORKDIR /work
COPY go.mod go.sum /work/
COPY math/go.mod math/go.sum /work/math/
COPY api/go.mod api/go.sum /work/api/
COPY log/go.mod log/go.sum /work/log/
COPY core/go.mod core/go.sum /work/core/
COPY collections/go.mod collections/go.sum /work/collections/
COPY store/go.mod store/go.sum /work/store/
COPY depinject/go.mod depinject/go.sum /work/depinject/
COPY x/tx/go.mod x/tx/go.sum /work/x/tx/
COPY x/protocolpool/go.mod x/protocolpool/go.sum /work/x/protocolpool/
COPY x/gov/go.mod x/gov/go.sum /work/x/gov/
COPY x/distribution/go.mod x/distribution/go.sum /work/x/distribution/
COPY x/slashing/go.mod x/slashing/go.sum /work/x/slashing/
COPY x/staking/go.mod x/staking/go.sum /work/x/staking/
COPY x/auth/go.mod x/auth/go.sum /work/x/auth/
COPY x/authz/go.mod x/authz/go.sum /work/x/authz/
COPY x/bank/go.mod x/bank/go.sum /work/x/bank/
COPY x/mint/go.mod x/mint/go.sum /work/x/mint/
COPY x/consensus/go.mod x/consensus/go.sum /work/x/consensus/
COPY x/accounts/go.mod x/accounts/go.sum /work/x/accounts/
COPY runtime/v2/go.mod runtime/v2/go.sum /work/runtime/v2/
COPY server/v2/go.mod server/v2/go.sum /work/server/v2/
COPY server/v2/appmanager/go.mod server/v2/appmanager/go.sum /work/server/v2/appmanager/
COPY server/v2/stf/go.mod server/v2/stf/go.sum /work/server/v2/stf/
COPY server/v2/cometbft/go.mod server/v2/cometbft/go.sum /work/server/v2/cometbft/
COPY core/testing/go.mod core/testing/go.sum /work/core/testing/

COPY db/go.mod db/go.sum /work/db/
RUN go mod download

COPY ./ /work
RUN LEDGER_ENABLED=false make clean build


FROM alpine AS run
FROM alpine:3.14 AS run
RUN apk add bash curl jq
COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh

VOLUME /simd
COPY --from=build /work/build/simd /simd/
WORKDIR /simd

EXPOSE 26656 26657
ENTRYPOINT ["/usr/bin/wrapper.sh"]
CMD ["start", "--log_format", "plain"]
STOPSIGNAL SIGTERM
VOLUME /simd
WORKDIR /simd

COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh
COPY --from=build /work/build/simd /simd/
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- "9090:9090"
- "2345:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.2
Expand All @@ -40,7 +40,7 @@ services:
- "9091:9090"
- "2346:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.3
Expand All @@ -62,7 +62,7 @@ services:
- "9092:9090"
- "2347:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.4
Expand All @@ -84,7 +84,7 @@ services:
- "9093:9090"
- "2348:2345"
volumes:
- ./.testnets:/data:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.5
Expand Down

0 comments on commit 0742e86

Please sign in to comment.