* build: fix build environment for the liveness test (#10551)
Extracted from #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 70a3a90f68
)
# Conflicts:
# Makefile
* fix conflict
Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
This commit is contained in:
parent
6a46c95500
commit
3ae5e0c38a
|
@ -219,7 +219,7 @@ jobs:
|
||||||
|
|
||||||
liveness-test:
|
liveness-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2.1.3
|
- uses: actions/setup-go@v2.1.3
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -483,13 +483,8 @@ proto-update-deps:
|
||||||
# Run a 4-node testnet locally
|
# Run a 4-node testnet locally
|
||||||
localnet-start: build-linux localnet-stop
|
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 $(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 \
|
$(DOCKER) run --rm -v $(CURDIR)/localnet:/data cosmossdk/simd-env \
|
||||||
--user $(shell id -u):$(shell id -g) \
|
testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test
|
||||||
-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-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
localnet-stop:
|
localnet-stop:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
all: simd-env
|
all: simd-env
|
||||||
|
|
||||||
simd-env:
|
simd-env:
|
||||||
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag cosmossdk/simd-env simd-env
|
docker build --tag cosmossdk/simd-env -f simd-env/Dockerfile \
|
||||||
|
$(shell git rev-parse --show-toplevel)
|
||||||
|
|
||||||
.PHONY: all simd-env
|
.PHONY: all simd-env
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
FROM ubuntu:18.04
|
FROM golang:1.17-alpine AS build
|
||||||
|
RUN apk add build-base git linux-headers
|
||||||
|
WORKDIR /work
|
||||||
|
COPY go.mod go.sum /work/
|
||||||
|
COPY db/go.mod db/go.sum /work/db/
|
||||||
|
RUN go mod download
|
||||||
|
COPY ./ /work
|
||||||
|
RUN LEDGER_ENABLED=false make clean build
|
||||||
|
|
||||||
RUN apt-get update && \
|
FROM alpine:3.14 AS run
|
||||||
apt-get -y upgrade && \
|
RUN apk add bash curl jq
|
||||||
apt-get -y install curl jq file
|
COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh
|
||||||
|
|
||||||
ARG UID=1000
|
VOLUME /simd
|
||||||
ARG GID=1000
|
COPY --from=build /work/build/simd /simd/
|
||||||
|
|
||||||
USER ${UID}:${GID}
|
|
||||||
VOLUME [ "/simd" ]
|
|
||||||
WORKDIR /simd
|
WORKDIR /simd
|
||||||
|
|
||||||
EXPOSE 26656 26657
|
EXPOSE 26656 26657
|
||||||
ENTRYPOINT ["/usr/bin/wrapper.sh"]
|
ENTRYPOINT ["/usr/bin/wrapper.sh"]
|
||||||
CMD ["start", "--log_format", "plain"]
|
CMD ["start", "--log_format", "plain"]
|
||||||
STOPSIGNAL SIGTERM
|
STOPSIGNAL SIGTERM
|
||||||
|
|
||||||
COPY wrapper.sh /usr/bin/wrapper.sh
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
BINARY=/simd/${BINARY:-simd}
|
BINARY=/simd/${BINARY:-simd}
|
||||||
ID=${ID:-0}
|
ID=${ID:-0}
|
||||||
|
@ -9,14 +11,7 @@ if ! [ -f "${BINARY}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BINARY_CHECK="$(file "$BINARY" | grep 'ELF 64-bit LSB executable, x86-64')"
|
export SIMDHOME="/data/node${ID}/simd"
|
||||||
|
|
||||||
if [ -z "${BINARY_CHECK}" ]; then
|
|
||||||
echo "Binary needs to be OS linux, ARCH amd64"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export SIMDHOME="/simd/node${ID}/simd"
|
|
||||||
|
|
||||||
if [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then
|
if [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then
|
||||||
"${BINARY}" --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}"
|
"${BINARY}" --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}"
|
||||||
|
|
|
@ -12,7 +12,7 @@ services:
|
||||||
- ID=0
|
- ID=0
|
||||||
- LOG=${LOG:-simd.log}
|
- LOG=${LOG:-simd.log}
|
||||||
volumes:
|
volumes:
|
||||||
- ./build:/simd:Z
|
- ./localnet:/data:Z
|
||||||
networks:
|
networks:
|
||||||
localnet:
|
localnet:
|
||||||
ipv4_address: 192.168.10.2
|
ipv4_address: 192.168.10.2
|
||||||
|
@ -28,7 +28,7 @@ services:
|
||||||
- ID=1
|
- ID=1
|
||||||
- LOG=${LOG:-simd.log}
|
- LOG=${LOG:-simd.log}
|
||||||
volumes:
|
volumes:
|
||||||
- ./build:/simd:Z
|
- ./localnet:/data:Z
|
||||||
networks:
|
networks:
|
||||||
localnet:
|
localnet:
|
||||||
ipv4_address: 192.168.10.3
|
ipv4_address: 192.168.10.3
|
||||||
|
@ -44,7 +44,7 @@ services:
|
||||||
- "1319:1317"
|
- "1319:1317"
|
||||||
- "9092:9090"
|
- "9092:9090"
|
||||||
volumes:
|
volumes:
|
||||||
- ./build:/simd:Z
|
- ./localnet:/data:Z
|
||||||
networks:
|
networks:
|
||||||
localnet:
|
localnet:
|
||||||
ipv4_address: 192.168.10.4
|
ipv4_address: 192.168.10.4
|
||||||
|
@ -60,7 +60,7 @@ services:
|
||||||
- "1320:1317"
|
- "1320:1317"
|
||||||
- "9093:9090"
|
- "9093:9090"
|
||||||
volumes:
|
volumes:
|
||||||
- ./build:/simd:Z
|
- ./localnet:/data:Z
|
||||||
networks:
|
networks:
|
||||||
localnet:
|
localnet:
|
||||||
ipv4_address: 192.168.10.5
|
ipv4_address: 192.168.10.5
|
||||||
|
|
Loading…
Reference in New Issue