Skip to content

Commit

Permalink
Merge PR: fix localnet start error (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylsGit authored Jan 8, 2021
1 parent dc04978 commit 529491d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ build-docker-okexchainnode:
$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: build-linux localnet-stop
@if ! [ -f build/node0/okexchaind/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/okexchaind:Z okexchain/node testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
localnet-start: localnet-stop
@if ! [ -f build/node0/okexchaind/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/okexchaind:Z okexchain/node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

# Stop testnet
Expand Down
4 changes: 2 additions & 2 deletions networks/local/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for the "gaiadnode" docker image.
# Makefile for the "okexchainnode" docker image.

all:
docker build --tag okexchain/node node
docker build --tag okexchain/node -f node/Dockerfile ../../../okexchain

.PHONY: all
32 changes: 18 additions & 14 deletions networks/local/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#FROM alpine:3.10.2
#
#RUN apk update && \
# apk upgrade && \
# apk --no-cache add curl jq file
FROM golang:stretch as build-env

# Changed from Alpine to Ubuntu because the keyring PR is linking to libc
# Alpine uses muslc instead of libc
# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y $PACKAGES

FROM ubuntu:18.04
WORKDIR /okexchain
# Add source files
COPY . .

RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install curl jq file
# build OKExChain
RUN make build-linux

# Final image
FROM golang:1.14 as final

VOLUME ["/okexchaind"]
WORKDIR /okexchaind
# Copy over binaries from the build-env
COPY --from=build-env /okexchain/build/okexchaind /usr/bin/okexchaind
COPY --from=build-env /okexchain/build/okexchaincli /usr/bin/okexchaincli
COPY --from=build-env /okexchain/networks/local/node/wrapper.sh /usr/bin/wrapper.sh

EXPOSE 26656 26657
ENTRYPOINT ["/usr/bin/wrapper.sh"]
CMD ["start"]
STOPSIGNAL SIGTERM

COPY wrapper.sh /usr/bin/wrapper.sh

18 changes: 2 additions & 16 deletions networks/local/node/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,17 @@
##
## Input parameters
##
BINARY=/okexchaind/${BINARY:-okexchaind}
ID=${ID:-0}
LOG=${LOG:-okexchaind.log}

##
## Assert linux binary
##
if ! [ -f "${BINARY}" ]; then
echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'okexchaind' E.g.: -e BINARY=okexchaind_my_test_version"
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

##
## Run binary with all parameters
##
export OKEXCHAINDHOME="/okexchaind/node${ID}/okexchaind"

if [ -d "$(dirname "${OKEXCHAINDHOME}"/"${LOG}")" ]; then
"${BINARY}" --home "${OKEXCHAINDHOME}" "$@" | tee "${OKExCHAINDHOME}/${LOG}"
okexchaind --chain-id okexchain-1 --home "${OKEXCHAINDHOME}" "$@" | tee "${OKExCHAINDHOME}/${LOG}"
else
"${BINARY}" --home "${OKEXCHAINDHOME}" "$@"
okexchaind --chain-id okexchain-1 --home "${OKEXCHAINDHOME}" "$@"
fi

0 comments on commit 529491d

Please sign in to comment.