|
1 | 1 | ################################################################
|
2 | 2 | #### protoc container
|
3 |
| -FROM golang:1.19-bullseye as protoc |
4 |
| - |
5 |
| -ENV DEBIAN_FRONTEND noninteractive |
6 |
| -ARG TARGETARCH |
7 |
| - |
8 |
| -WORKDIR /protoc |
9 |
| - |
10 |
| -#### |
11 |
| -#### protoc + protoc-gen-grpc-web |
12 |
| -#### |
13 |
| - |
14 |
| -RUN \ |
15 |
| - apt-get update \ |
16 |
| - && apt-get install -y \ |
17 |
| - wget unzip \ |
18 |
| - && apt-get clean \ |
19 |
| - && rm -rf /var/lib/apt/lists/* |
20 |
| - |
21 |
| -# https://github.com/protocolbuffers/protobuf/releases/ |
22 |
| -ARG PROTOC_VERSION=21.12 |
23 |
| -ARG PROTOC_VERSION_GITHUB_RELEASE=v21.12 |
24 |
| - |
25 |
| -ARG PROTOC_GEN_GRPC_WEB_VERSION=1.4.2 |
26 |
| - |
27 |
| -ARG PROTOC_VERSION |
| 3 | +FROM golang:1.23-alpine AS go |
28 | 4 |
|
| 5 | +ENV CGO_ENABLED=0 |
29 | 6 | RUN \
|
30 |
| - case $TARGETARCH in \ |
31 |
| - amd64) \ |
32 |
| - export PROTOC_ARCH=x86_64 \ |
33 |
| - ;; \ |
34 |
| - arm64) \ |
35 |
| - export PROTOC_ARCH=aarch_64 \ |
36 |
| - ;; \ |
37 |
| - *) \ |
38 |
| - echo "Unsupported architecture >$TARGETARCH<" &&\ |
39 |
| - exit 1 \ |
40 |
| - ;; \ |
41 |
| - esac &&\ |
42 |
| - export PROTOC_ARCHIVE=protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip &&\ |
43 |
| - wget https://github.com/protocolbuffers/protobuf/releases/download/${PROTOC_VERSION_GITHUB_RELEASE}/${PROTOC_ARCHIVE} &&\ |
44 |
| - unzip ${PROTOC_ARCHIVE} -d /protoc &&\ |
45 |
| - rm ${PROTOC_ARCHIVE} |
46 |
| - |
47 |
| -# https://github.com/protocolbuffers/protobuf/releases/download/v21.0-rc-2/protoc-21.0-rc-2-linux-x86_64.zip |
48 |
| -# https://github.com/protocolbuffers/protobuf/releases/download/v21.0-rc2/protoc-21.0-rc-2-linux-x86_64.zip |
49 |
| - |
50 |
| -ARG PROTOC_GEN_GRPC_WEB_VERSION |
51 |
| -RUN wget -O /protoc/bin/protoc-gen-grpc-web https://github.com/grpc/grpc-web/releases/download/${PROTOC_GEN_GRPC_WEB_VERSION}/protoc-gen-grpc-web-${PROTOC_GEN_GRPC_WEB_VERSION}-linux-x86_64 |
52 |
| -RUN chmod +x /protoc/bin/protoc-gen-grpc-web |
53 |
| - |
54 |
| -#### |
55 |
| -#### golang tools |
56 |
| -#### |
57 |
| - |
58 |
| -COPY / /protoc |
59 |
| - |
60 |
| -RUN \ |
61 |
| - git clone https://github.com/googleapis/googleapis.git --branch master --single-branch /protoc/googleapis &&\ |
62 |
| - rm -rf /protoc/googleapis/.git |
63 |
| - |
64 |
| -ENV GOBIN=/protoc/bin/ |
65 |
| -RUN go install \ |
66 |
| - github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \ |
67 |
| - github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \ |
68 |
| - google.golang.org/protobuf/cmd/protoc-gen-go \ |
69 |
| - google.golang.org/grpc/cmd/protoc-gen-go-grpc \ |
70 |
| - github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc \ |
71 |
| - \ |
72 |
| - github.com/bufbuild/buf/cmd/buf \ |
73 |
| - github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go \ |
74 |
| - github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking \ |
75 |
| - github.com/bufbuild/buf/cmd/protoc-gen-buf-lint |
76 |
| - |
| 7 | + go install github.com/bufbuild/buf/cmd/buf@latest &&\ |
| 8 | + go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest &&\ |
| 9 | + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest &&\ |
| 10 | + go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest |
77 | 11 |
|
78 | 12 |
|
79 | 13 | ################################################################
|
80 | 14 | #### Final container
|
81 |
| -FROM debian:bullseye |
82 |
| -ENV DEBIAN_FRONTEND noninteractive |
| 15 | +FROM node:lts-alpine AS final |
83 | 16 |
|
84 | 17 | WORKDIR /protoc
|
85 | 18 |
|
86 |
| -COPY --from=protoc /protoc /protoc |
| 19 | +COPY --from=go /go/bin /usr/local/bin |
87 | 20 |
|
88 | 21 | RUN \
|
89 |
| - apt-get update &&\ |
90 |
| - apt-get install -y curl clang-format &&\ |
91 |
| - curl -sL https://deb.nodesource.com/setup_16.x | bash - &&\ |
92 |
| - apt-get install -y nodejs &&\ |
93 |
| - apt-get clean &&\ |
94 |
| - rm -rf /var/lib/apt/lists/* &&\ |
95 |
| - \ |
96 |
| - npm install &&\ |
97 |
| - npm run install-hack &&\ |
98 |
| - \ |
99 |
| - chmod -R +x /protoc/bin &&\ |
100 |
| - mv /protoc/bin/protoc /protoc/bin/protoc-original &&\ |
101 |
| - mv /protoc/bin/* /bin/ &&\ |
102 |
| - mv /protoc/protoc /bin/ &&\ |
103 |
| - ln -s /protoc/node_modules/.bin/protoc-gen-connect-web /bin/ &&\ |
104 |
| - ln -s /protoc/node_modules/.bin/protoc-gen-es /bin/ &&\ |
105 |
| - ln -s /protoc/node_modules/.bin/protoc-gen-ts /bin/ &&\ |
106 |
| - ln -s /protoc/node_modules/.bin/protoc-gen-ts_proto /bin/ &&\ |
107 |
| - ln -s /protoc/pbjs /bin/pbjs &&\ |
108 |
| - ln -s /protoc/pbts /bin/pbts &&\ |
109 |
| - \ |
110 |
| - chmod -R 0777 /protoc |
111 |
| - |
112 |
| -# https://superuser.com/questions/1409618/renaming-a-file-with-mv-cannot-move-to-a-subdirectory-of-itself |
| 22 | + npm install -g @connectrpc/protoc-gen-connect-es@"^1.0.0" @bufbuild/protoc-gen-es@"^1.0.0" |
113 | 23 |
|
114 | 24 | WORKDIR /mnt
|
0 commit comments