From 3bcfe931f921add91bd12503e9221c8661bb5fff Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 15 Jan 2021 13:44:54 +0100 Subject: [PATCH] make+lnrpc: compile mobile RPC with docker too Now that we have a base docker image that has all our RPC compilation dependencies installed, we can also run the mobile RPC compilation there. This removes the need to install falafel and goimports on the local machine. --- Makefile | 11 ++--------- lnrpc/Dockerfile | 11 ++++++++++- lnrpc/gen_protos.sh | 6 ++++++ lnrpc/gen_protos_docker.sh | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 05617ab3..5a321c03 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ BTCD_PKG := github.com/btcsuite/btcd GOVERALLS_PKG := github.com/mattn/goveralls LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint GOACC_PKG := github.com/ory/go-acc -FALAFEL_PKG := github.com/lightninglabs/falafel GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports GOFUZZ_BUILD_PKG := github.com/dvyukov/go-fuzz/go-fuzz-build GOFUZZ_PKG := github.com/dvyukov/go-fuzz/go-fuzz @@ -37,7 +36,6 @@ BTCD_COMMIT := $(shell cat go.mod | \ LINT_COMMIT := v1.18.0 GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5 -FALAFEL_COMMIT := v0.7.1 GOFUZZ_COMMIT := 21309f307f61 DEPGET := cd /tmp && GO111MODULE=on go get -v @@ -113,10 +111,6 @@ btcd: @$(call print, "Installing btcd.") $(DEPGET) $(BTCD_PKG)@$(BTCD_COMMIT) -falafel: - @$(call print, "Installing falafel.") - $(DEPGET) $(FALAFEL_PKG)@$(FALAFEL_COMMIT) - goimports: @$(call print, "Installing goimports.") $(DEPGET) $(GOIMPORTS_PKG) @@ -277,9 +271,9 @@ sample-conf-check: @$(call print, "Making sure every flag has an example in the sample-lnd.conf file") for flag in $$(GO_FLAGS_COMPLETION=1 go run -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd -- | grep -v help | cut -c3-); do if ! grep -q $$flag sample-lnd.conf; then echo "Command line flag --$$flag not added to sample-lnd.conf"; exit 1; fi; done -mobile-rpc: falafel goimports +mobile-rpc: @$(call print, "Creating mobile RPC from protos.") - cd ./mobile; ./gen_bindings.sh $(FALAFEL_COMMIT) + cd ./lnrpc; COMPILE_MOBILE=1 ./gen_protos_docker.sh vendor: @$(call print, "Re-creating vendor directory.") @@ -316,7 +310,6 @@ clean: unit \ unit-cover \ unit-race \ - falafel \ goveralls \ travis-race \ travis-cover \ diff --git a/lnrpc/Dockerfile b/lnrpc/Dockerfile index ee8a62cf..fa04a78c 100644 --- a/lnrpc/Dockerfile +++ b/lnrpc/Dockerfile @@ -11,11 +11,20 @@ RUN apt-get update && apt-get install -y \ ARG PROTOC_GEN_VERSION ARG GRPC_GATEWAY_VERSION +ENV FALAFEL_VERSION="v0.7.1" +ENV GOCACHE=/tmp/build/.cache +ENV GOMODCACHE=/tmp/build/.modcache + RUN cd /tmp \ + && mkdir -p /tmp/build/.cache \ + && mkdir -p /tmp/build/.modcache \ && export GO111MODULE=on \ && go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_VERSION} \ && go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \ - && go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION} + && go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION} \ + && go get github.com/lightninglabs/falafel@${FALAFEL_VERSION} \ + && go get golang.org/x/tools/cmd/goimports \ + && chmod -R 777 /tmp/build/ WORKDIR /build diff --git a/lnrpc/gen_protos.sh b/lnrpc/gen_protos.sh index 6c262573..13892fee 100755 --- a/lnrpc/gen_protos.sh +++ b/lnrpc/gen_protos.sh @@ -42,3 +42,9 @@ pushd lnrpc format generate popd + +if [[ "$COMPILE_MOBILE" == "1" ]]; then + pushd mobile + ./gen_bindings.sh $FALAFEL_VERSION + popd +fi diff --git a/lnrpc/gen_protos_docker.sh b/lnrpc/gen_protos_docker.sh index f29c4629..deebc4fb 100755 --- a/lnrpc/gen_protos_docker.sh +++ b/lnrpc/gen_protos_docker.sh @@ -19,5 +19,6 @@ docker run \ --rm \ --user "$UID:$(id -g)" \ -e UID=$UID \ + -e COMPILE_MOBILE \ -v "$DIR/../:/build" \ lnd-protobuf-builder