-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (35 loc) · 2.26 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM golang:1.21-alpine as go-grpc-builder
# available versions - https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc?tab=versions
ARG PROTOC_GEN_GO_GRPC_VERSION=1.3.0
ENV GOBIN=/out
RUN mkdir /out
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC_VERSION}
FROM python:3-alpine
RUN apk add curl unzip
# protobuf (protoc) releases - https://github.com/protocolbuffers/protobuf/releases
ARG PROTOBUF_VERSION=24.4
# protoc-gen-go releases - https://github.com/protocolbuffers/protobuf-go/releases
ARG PROTOC_GEN_GO_VERSION=1.31.0
# grpcio-tools releases - https://pypi.org/project/grpcio-tools/#history
ARG PYTHON_GRPCIO_TOOLS_VERSION=1.59.2
# protoc-gen-doc releases - https://github.com/pseudomuto/protoc-gen-doc/releases
ARG PROTOC_GEN_DOC_VERSION=1.5.1
# googleapis commit - https://github.com/googleapis/googleapis
ARG GOOGLE_APIS_VERSION=5f2465117c6ec4bd8d7b5d23fc8e436608156e64
ENV OUTDIR=/out
RUN mkdir /protobuf && mkdir /in && mkdir /out && mkdir /googleapis
# Protoc compiler installation
RUN curl -NL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip && unzip -d /protobuf /tmp/protoc.zip
# protoc-gen-go installation
RUN curl -NL https://github.com/protocolbuffers/protobuf-go/releases/download/v${PROTOC_GEN_GO_VERSION}/protoc-gen-go.v${PROTOC_GEN_GO_VERSION}.linux.amd64.tar.gz | tar xvz -C /protobuf
RUN install /protobuf/bin/protoc /protobuf/protoc-gen-go /usr/bin
# copy protoc-gen-go-grpc
COPY --from=go-grpc-builder /out/ /usr/bin/
# install grpcio-tools for python grpc generation
RUN pip3 install grpcio-tools==${PYTHON_GRPCIO_TOOLS_VERSION}
# download protoc-gen-doc
RUN curl -Lo -X GET https://github.com/pseudomuto/protoc-gen-doc/releases/download/v${PROTOC_GEN_DOC_VERSION}/protoc-gen-doc_${PROTOC_GEN_DOC_VERSION}_linux_amd64.tar.gz | tar xvz -C /tmp && mv /tmp/protoc-gen-doc /usr/bin
# download googleapis commit 4c3b682f501bb965d34c3d4fc3461edfccf962db
# googleapis does not have a tagged release, so we pin to the latest available at the time
RUN curl -Lo -X GET https://github.com/googleapis/googleapis/archive/${GOOGLE_APIS_VERSION}.tar.gz | tar xvz -C /tmp && mv /tmp/googleapis-${GOOGLE_APIS_VERSION}/* /googleapis
WORKDIR /in