From 72fd6cf5a9ab3aaea90597903eeab3a66082337d Mon Sep 17 00:00:00 2001 From: Grigory Gavrin <96040376+grishagavrin@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:05:35 +0300 Subject: [PATCH] #20 codegen inside docker finish do codegen inside docker with fixed versions of protoc + protoc-gen-go --- Makefile | 7 +++++-- generate-protobuf.Dockerfile | 22 ++++++++++++++++++++++ generate_proto.sh | 6 ++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 generate-protobuf.Dockerfile create mode 100644 generate_proto.sh diff --git a/Makefile b/Makefile index cc9d275..ddb9c94 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,5 @@ -proto: - protoc --go_out=. --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=. --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto -Iapi -Iapi/protos -Iapi/protos/annotations -Iapi/draft -Iapi/draft/protos api/{*.proto,protos/*.proto,protos/annotations/*.proto,draft/*.proto,draft/protos/*.proto} +proto: protobuf-3 + +protobuf-3: + docker build -f generate-protobuf.Dockerfile . -t ydb-go-sdk-proto-generator-env-3 --build-arg PROTOC_VER=25.3 --build-arg PTOCOC_GEN_GO=1.32.0 --build-arg PROTOC_GEN_GO_GRPC=1.3.0 + docker run -v ${PWD}:/github.com/ydb-platform/ydb-go-genproto/volumes -it ydb-go-sdk-proto-generator-env-3:latest bash generate_proto.sh diff --git a/generate-protobuf.Dockerfile b/generate-protobuf.Dockerfile new file mode 100644 index 0000000..28d9d97 --- /dev/null +++ b/generate-protobuf.Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.16-alpine + +ARG PROTOC_VER=25.3 +ARG PTOCOC_GEN_GO=1.32.0 +ARG PROTOC_GEN_GO_GRPC=1.3.0 +ENV GOBIN=/github.com/ydb-platform/ydb-go-genproto/ +ENV PATH="${PATH}:/github.com/ydb-platform/ydb-go-genproto/" + +COPY . /github.com/ydb-platform/ydb-go-genproto/ +RUN mkdir /github.com/ydb-platform/ydb-go-genproto/volumes +WORKDIR /github.com/ydb-platform/ydb-go-genproto/ + +RUN \ + wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/protoc-${PROTOC_VER}-linux-x86_64.zip &&\ + unzip -o protoc-*.zip -d /usr/local bin/protoc &&\ + unzip -o protoc-*.zip -d /usr/local 'include/*' &&\ + rm -f protoc-*.zip + +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PTOCOC_GEN_GO} +RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC} +RUN apk add bash + diff --git a/generate_proto.sh b/generate_proto.sh new file mode 100644 index 0000000..a15a0cf --- /dev/null +++ b/generate_proto.sh @@ -0,0 +1,6 @@ +#!/bin/bash +protoc --go_out=volumes --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=volumes --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto --proto_path=/github.com/ydb-platform/ydb-go-genproto/api/ /github.com/ydb-platform/ydb-go-genproto/api/*.proto +protoc --go_out=volumes --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=volumes --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto --proto_path=/github.com/ydb-platform/ydb-go-genproto/api/ /github.com/ydb-platform/ydb-go-genproto/api/protos/*.proto --experimental_allow_proto3_optional +protoc --go_out=volumes --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=volumes --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto --proto_path=/github.com/ydb-platform/ydb-go-genproto/api/ /github.com/ydb-platform/ydb-go-genproto/api/protos/annotations/*.proto +protoc --go_out=volumes --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=volumes --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto --proto_path=/github.com/ydb-platform/ydb-go-genproto/api/ /github.com/ydb-platform/ydb-go-genproto/api/draft/protos/*.proto --experimental_allow_proto3_optional +protoc --go_out=volumes --go_opt=module=github.com/ydb-platform/ydb-go-genproto --go-grpc_out=volumes --go-grpc_opt=module=github.com/ydb-platform/ydb-go-genproto --proto_path=/github.com/ydb-platform/ydb-go-genproto/api/ /github.com/ydb-platform/ydb-go-genproto/api/draft/*.proto