Skip to content

Commit

Permalink
Update codegen base image (#4968)
Browse files Browse the repository at this point in the history
* Update codegen base image from alpine to debian to update go version and use protoc-gen-js

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Add generated files

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Add .gitatributes

Signed-off-by: Yoshiki Fujikane <[email protected]>

---------

Signed-off-by: Yoshiki Fujikane <[email protected]>
  • Loading branch information
ffjlabo authored Jun 13, 2024
1 parent 8129078 commit 7e27cad
Show file tree
Hide file tree
Showing 55 changed files with 234 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*_pb.js linguist-generated=true
2 changes: 1 addition & 1 deletion pkg/app/helloworld/service/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/helloworld/service/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/pipedv1/cmd/piped/service/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/pipedv1/cmd/piped/service/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/apiservice/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/apiservice/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/pipedservice/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/pipedservice/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions pkg/app/server/service/webservice/service.pb.auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/webservice/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/app/server/service/webservice/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/analysis_result.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/apikey.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/application.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/application_live_state.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/command.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/deployment.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/deployment_chain.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/insight.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/logblock.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/notificationevent.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/piped.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/piped_stat.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/planpreview.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/project.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/rbac.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/role.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/model/user.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/plugin/api/v1alpha1/platform/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/plugin/api/v1alpha1/platform/api_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions tool/codegen/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Builder image to build go program.
FROM golang:1.20.4-alpine3.16 as BUILDER
FROM golang:1.22.4 as BUILDER

COPY protoc-gen-auth /protoc-gen-auth
RUN cd /protoc-gen-auth \
&& go build -o /usr/local/bin/protoc-gen-auth . \
&& chmod +x /usr/local/bin/protoc-gen-auth

# Codegen image which is actually being used.
FROM golang:1.20.4-alpine3.16
FROM golang:1.22.4

# This is version of protobuf installed in the image.
# See https://pkgs.alpinelinux.org/packages?name=protobuf&branch=v3.16
# NOTE: Start from protobuf v3.20.1, the protoc-gen-js is not included in protobuf package.
ENV PROTOC_VER=3.18.1
ENV PROTOC_GEN_JS_VER=3.21.2
ENV PROTOC_GEN_GO_VER=1.27.1
ENV PROTOC_GEN_GRPC_WEB_VER=1.3.1
ENV PROTOC_GEN_GO_GRPC_VER=1.2.0
ENV PROTOC_GEN_VALIDATE_VER=0.6.6
ENV GOMOCK_VER=1.6.0

# dependecies and protoc
RUN apk --no-cache add wget bash protobuf-dev protobuf
RUN apt update && apt install -y protobuf-compiler

# protoc-gen-go
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOC_GEN_GO_VER}
Expand All @@ -41,6 +41,17 @@ RUN go install github.com/envoyproxy/protoc-gen-validate@v${PROTOC_GEN_VALIDATE_
&& rm protoc-gen-validate.tar.gz \
&& mv /go/src/github.com/envoyproxy/protoc-gen-validate-${PROTOC_GEN_VALIDATE_VER} /go/src/github.com/envoyproxy/protoc-gen-validate

# protoc-gen-js
# This is a workaround to use it https://github.com/protocolbuffers/protobuf-javascript/issues/127#issuecomment-1361047597
RUN for target in x86_64 aarch_64; do \
mkdir /protoc-gen-js-${target} && cd /protoc-gen-js-${target} \
&& wget https://github.com/protocolbuffers/protobuf-javascript/releases/download/v${PROTOC_GEN_JS_VER}/protobuf-javascript-${PROTOC_GEN_JS_VER}-linux-${target}.tar.gz \
&& tar xvfz protobuf-javascript-${PROTOC_GEN_JS_VER}-linux-${target}.tar.gz \
&& chmod +x bin/protoc-gen-js \
&& rm -rf protobuf-javascript-${PROTOC_GEN_JS_VER}-linux-${target}.tar.gz; \
done && \
mv /protoc-gen-js-aarch_64/ /protoc-gen-js-aarch64/

# protoc-gen-auth
COPY --from=BUILDER /usr/local/bin/protoc-gen-auth /usr/local/bin/

Expand Down
13 changes: 13 additions & 0 deletions tool/codegen/codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ jsOutDirs=(
"web/api_client"
)

# Check the arch for protc-gen-js
arch=$(uname -m);
protocGenJsSupportArch=("x86_64" "aarch64")
if [[ ! " ${protocGenJsSupportArch[@]} " =~ " ${arch} " ]]; then
echo "Unsupported architecture: $arch"
exit 1
fi

protocGenJsIncludePath="/protoc-gen-js-${arch}"
protocGenJsPath="/protoc-gen-js-${arch}/bin/protoc-gen-js"

i=0
while [ $i -lt ${#jsProtoDirs[*]} ]; do
inDir=${jsProtoDirs[$i]}
Expand All @@ -72,7 +83,9 @@ while [ $i -lt ${#jsProtoDirs[*]} ]; do
echo "generating new JS files..."
protoc \
-I . \
-I ${protocGenJsIncludePath} \
-I /go/src/github.com/envoyproxy/protoc-gen-validate \
--plugin=protoc-gen-js=${protocGenJsPath} \
--js_out=import_style=commonjs:. \
--grpc-web_out=import_style=commonjs+dts,mode=grpcweb:. \
${inDir}/*.proto
Expand Down
Loading

0 comments on commit 7e27cad

Please sign in to comment.