Skip to content

Commit

Permalink
#20 codegen inside docker
Browse files Browse the repository at this point in the history
finish do codegen inside docker with fixed versions of protoc + protoc-gen-go
  • Loading branch information
grishagavrin committed Feb 17, 2024
1 parent 1623f57 commit 72fd6cf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions generate-protobuf.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions generate_proto.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 72fd6cf

Please sign in to comment.