Make build-proto.sh generic to be able to build proto files locally
MODIFY
build/Dockerfile
build/Dockerfile
@@ -10,6 +10,8 @@ ARG GOOS=linux
ARG GOARCH=amd64
ARG CGO_ENABLED=0
+RUN build/build-proto.sh
+
RUN mkdir -p build/_output/bin \
&& GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
go build -mod=vendor -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \

MODIFY
build/build-proto.sh
build/build-proto.sh
set -o errexit
set -o xtrace
+proto_compiler=protoc
+
go get \
github.com/golang/protobuf/protoc-gen-go \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
@@ -11,6 +13,22 @@ go get \
go install github.com/go-swagger/go-swagger/cmd/swagger
-protoc -I build/third_party/googleapis -I build/third_party/grpc-gateway -I vendor/github.com/Percona-Lab/percona-version-service/api --openapiv2_out=./openapi vendor/github.com/Percona-Lab/percona-version-service/api/version.proto
+rm -rf versionserviceclient
+
+if ! protoc --version &> /dev/null
+then
+ apt-get update && apt-get install unzip
+
+ curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip
+
+ unzip protoc-3.12.1-linux-x86_64.zip -d $HOME/.local
+
+ proto_compiler=$HOME/.local/bin/protoc
+
+fi
+
+mkdir -p openapi
+
+$proto_compiler -I build/third_party/googleapis -I build/third_party/grpc-gateway -I vendor/github.com/Percona-Lab/percona-version-service/api --openapiv2_out=./openapi vendor/github.com/Percona-Lab/percona-version-service/api/version.proto
swagger generate client -f openapi/version.swagger.json -c versionserviceclient -m versionserviceclient/models

Make build-proto.sh generic to be able to build proto files locally