From 9c827807425bd7d62de4bc813cb9549a91b1bc36 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Wed, 11 Sep 2019 05:29:28 -0400 Subject: [PATCH] Add cleveldb build for Amazon Linux (#3976) * Add cleveldb build for Amazon Linux In attempting to build Tendermint binaries with cleveldb support that we can use for load testing (see https://github.com/interchainio/got), it became apparent that we need a bit of a simpler build process for this kind of executable. Since we're basing our load testing infrastructure on Amazon Linux, it makes sense to support such a build process for Amazon Linux in a platform-independent way. This PR allows one to simply build the Amazon Linux-compatible binary using Docker on one's local machine. It first builds an Amazon Linux-based build image with Go v1.12.9, and then it uses that image to build the cleveldb version of Tendermint. This should, in theory, be compatible with CentOS too, but that's yet to be tested. * Add comment describing the new Makefile target * Add missing PHONY entry for new Makefile target * Expand on Makefile comment --- DOCKER/Dockerfile.build_c-amazonlinux | 28 +++++++++++++++++++++++++++ DOCKER/Makefile | 3 +++ Makefile | 9 ++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 DOCKER/Dockerfile.build_c-amazonlinux diff --git a/DOCKER/Dockerfile.build_c-amazonlinux b/DOCKER/Dockerfile.build_c-amazonlinux new file mode 100644 index 000000000..64babe3ae --- /dev/null +++ b/DOCKER/Dockerfile.build_c-amazonlinux @@ -0,0 +1,28 @@ +FROM amazonlinux:2 + +RUN yum -y update && \ + yum -y install wget + +RUN wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ + rpm -ivh epel-release-latest-7.noarch.rpm + +RUN yum -y groupinstall "Development Tools" +RUN yum -y install leveldb-devel which + +ENV GOVERSION=1.12.9 + +RUN cd /tmp && \ + wget https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz && \ + tar -C /usr/local -xf go${GOVERSION}.linux-amd64.tar.gz && \ + mkdir -p /go/src && \ + mkdir -p /go/bin + +ENV PATH=$PATH:/usr/local/go/bin:/go/bin +ENV GOBIN=/go/bin +ENV GOPATH=/go/src + +RUN mkdir -p /tendermint +WORKDIR /tendermint + +CMD ["/usr/bin/make", "build_c"] + diff --git a/DOCKER/Makefile b/DOCKER/Makefile index 32510ebbb..41fb60ac8 100644 --- a/DOCKER/Makefile +++ b/DOCKER/Makefile @@ -13,4 +13,7 @@ build_testing: push_develop: docker push "tendermint/tendermint:develop" +build_amazonlinux_buildimage: + docker build -t "tendermint/tendermint:build_c-amazonlinux" -f Dockerfile.build_c-amazonlinux . + .PHONY: build build_develop push push_develop diff --git a/Makefile b/Makefile index fe76f0862..03a88a853 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,13 @@ build: build_c: CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" -o $(OUTPUT) ./cmd/tendermint/ +# Runs `make build_c` from within an Amazon Linux (v2)-based Docker build +# container in order to build an Amazon Linux-compatible binary. Produces a +# compatible binary at ./build/tendermint +build_c-amazonlinux: + $(MAKE) -C ./DOCKER build_amazonlinux_buildimage + docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux + build_race: CGO_ENABLED=1 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint @@ -327,4 +334,4 @@ contract-tests: # To avoid unintended conflicts with file names, always add to .PHONY # unless there is a reason not to. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html -.PHONY: check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests +.PHONY: check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests build_c-amazonlinux