lnd/lnrpc/gen_protos_docker.sh
Oliver Gugger 63af63dfa8
lnrpc: avoid needing to download Golang
Because the Go version used to run the `go list` commands is below the
minimum version specified in the main go.mod file, every time the `make
rpc` command is executed, the Golang runtime is downloaded twice, which
looks like this and takes a couple of seconds at least:

go: downloading go1.21.4 (linux/amd64)
go: downloading go1.21.4 (linux/amd64)

We fix this by using the correct minimum version.
2024-08-06 18:38:10 +02:00

31 lines
945 B
Bash
Executable File

#!/bin/bash
set -e
# Directory of the script file, independent of where it's called from.
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
# golang docker image version used in this script.
GO_IMAGE=docker.io/library/golang:1.21.4-alpine
PROTOBUF_VERSION=$(docker run --rm -v $DIR/../:/lnd -w /lnd $GO_IMAGE \
go list -f '{{.Version}}' -m google.golang.org/protobuf)
GRPC_GATEWAY_VERSION=$(docker run --rm -v $DIR/../:/lnd -w /lnd $GO_IMAGE \
go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway/v2)
echo "Building protobuf compiler docker image..."
docker build -t lnd-protobuf-builder \
--build-arg PROTOBUF_VERSION="$PROTOBUF_VERSION" \
--build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \
.
echo "Compiling and formatting *.proto files..."
docker run \
--rm \
--user "$UID:$(id -g)" \
-e UID=$UID \
-e COMPILE_MOBILE \
-e SUBSERVER_PREFIX \
-v "$DIR/../:/build" \
lnd-protobuf-builder