Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix build environment for the liveness test (backport #10551) #10552

Merged
merged 2 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:

liveness-test:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,18 @@ 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)
<<<<<<< HEAD
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
>>>>>>> 70a3a90f6 (build: fix build environment for the liveness test (#10551))
docker-compose up -d

localnet-stop:
Expand Down
3 changes: 2 additions & 1 deletion contrib/images/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
all: 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
25 changes: 14 additions & 11 deletions contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
apt-get -y upgrade && \
apt-get -y install curl jq file
FROM alpine:3.14 AS run
RUN apk add bash curl jq
COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh

ARG UID=1000
ARG GID=1000

USER ${UID}:${GID}
VOLUME [ "/simd" ]
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

COPY wrapper.sh /usr/bin/wrapper.sh
11 changes: 3 additions & 8 deletions contrib/images/simd-env/wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
set -euo pipefail
set -x

BINARY=/simd/${BINARY:-simd}
ID=${ID:-0}
Expand All @@ -9,14 +11,7 @@ if ! [ -f "${BINARY}" ]; then
exit 1
fi

BINARY_CHECK="$(file "$BINARY" | grep 'ELF 64-bit LSB executable, x86-64')"

if [ -z "${BINARY_CHECK}" ]; then
echo "Binary needs to be OS linux, ARCH amd64"
exit 1
fi

export SIMDHOME="/simd/node${ID}/simd"
export SIMDHOME="/data/node${ID}/simd"

if [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then
"${BINARY}" --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}"
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- ID=0
- LOG=${LOG:-simd.log}
volumes:
- ./build:/simd:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.2
Expand All @@ -28,7 +28,7 @@ services:
- ID=1
- LOG=${LOG:-simd.log}
volumes:
- ./build:/simd:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.3
Expand All @@ -44,7 +44,7 @@ services:
- "1319:1317"
- "9092:9090"
volumes:
- ./build:/simd:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.4
Expand All @@ -60,7 +60,7 @@ services:
- "1320:1317"
- "9093:9090"
volumes:
- ./build:/simd:Z
- ./localnet:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.5
Expand Down