2021-05-25 16:33:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Directory of the script file, independent of where it's called from.
|
|
|
|
|
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
|
|
|
|
|
2025-05-21 14:08:54 +02:00
|
|
|
# Get versions from looprpc go.mod
|
2021-07-29 13:32:53 +02:00
|
|
|
PROTOBUF_VERSION=$(go list -f '{{.Version}}' -m google.golang.org/protobuf)
|
|
|
|
|
GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway/v2)
|
2021-05-25 16:33:44 +02:00
|
|
|
|
2025-05-21 14:08:54 +02:00
|
|
|
# Get lnd directory from parent go.mod to use the correct version
|
|
|
|
|
lnd_dir=$(cd .. && go list -f '{{.Dir}}' -m github.com/lightningnetwork/lnd)
|
|
|
|
|
echo "Using lnd directory: ${lnd_dir}"
|
|
|
|
|
|
2021-05-25 16:33:44 +02:00
|
|
|
echo "Building protobuf compiler docker image..."
|
2021-07-29 13:32:53 +02:00
|
|
|
docker build -t loop-protobuf-builder \
|
|
|
|
|
--build-arg PROTOBUF_VERSION="$PROTOBUF_VERSION" \
|
2021-05-25 16:33:44 +02:00
|
|
|
--build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \
|
|
|
|
|
.
|
|
|
|
|
|
|
|
|
|
echo "Compiling and formatting *.proto files..."
|
|
|
|
|
docker run \
|
|
|
|
|
--rm \
|
|
|
|
|
--user $UID:$UID \
|
|
|
|
|
-e UID=$UID \
|
2025-05-21 14:08:54 +02:00
|
|
|
-e LND_DIR=/lnd \
|
2021-05-25 16:33:44 +02:00
|
|
|
-v "$DIR/../:/build" \
|
2025-05-21 14:08:54 +02:00
|
|
|
-v "${lnd_dir}:/lnd" \
|
|
|
|
|
loop-protobuf-builder
|