forked from uber/prototool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
94 lines (79 loc) · 3.7 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM golang:1.12.4-alpine3.9 as builder
RUN apk add --update --no-cache build-base curl git upx && \
rm -rf /var/cache/apk/*
ENV GOLANG_PROTOBUF_VERSION=1.3.1 \
GOGO_PROTOBUF_VERSION=1.2.1
RUN GO111MODULE=on go get \
github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gofast@v${GOGO_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gogofast@v${GOGO_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gogoslick@v${GOGO_PROTOBUF_VERSION} && \
mv /go/bin/protoc-gen-go* /usr/local/bin/
ENV GRPC_GATEWAY_VERSION=1.8.5
RUN curl -sSL \
https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v${GRPC_GATEWAY_VERSION}/protoc-gen-grpc-gateway-v${GRPC_GATEWAY_VERSION}-linux-x86_64 \
-o /usr/local/bin/protoc-gen-grpc-gateway && \
curl -sSL \
https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v${GRPC_GATEWAY_VERSION}/protoc-gen-swagger-v${GRPC_GATEWAY_VERSION}-linux-x86_64 \
-o /usr/local/bin/protoc-gen-swagger && \
chmod +x /usr/local/bin/protoc-gen-grpc-gateway && \
chmod +x /usr/local/bin/protoc-gen-swagger
ENV GRPC_WEB_VERSION=1.0.4
RUN curl -sSL \
https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64 \
-o /usr/local/bin/protoc-gen-grpc-web && \
chmod +x /usr/local/bin/protoc-gen-grpc-web
ENV YARPC_VERSION=1.37.3
RUN git clone --depth 1 -b v${YARPC_VERSION} https://github.com/yarpc/yarpc-go.git /go/src/go.uber.org/yarpc && \
cd /go/src/go.uber.org/yarpc && \
GO111MODULE=on go mod init && \
GO111MODULE=on go install ./encoding/protobuf/protoc-gen-yarpc-go && \
mv /go/bin/protoc-gen-yarpc-go /usr/local/bin/
ENV TWIRP_VERSION=5.7.0
RUN curl -sSL \
https://github.com/twitchtv/twirp/releases/download/v${TWIRP_VERSION}/protoc-gen-twirp-Linux-x86_64 \
-o /usr/local/bin/protoc-gen-twirp && \
curl -sSL \
https://github.com/twitchtv/twirp/releases/download/v${TWIRP_VERSION}/protoc-gen-twirp_python-Linux-x86_64 \
-o /usr/local/bin/protoc-gen-twirp_python && \
chmod +x /usr/local/bin/protoc-gen-twirp && \
chmod +x /usr/local/bin/protoc-gen-twirp_python
ENV PROTOBUF_VERSION=3.6.1
RUN mkdir -p /tmp/protoc && \
curl -sSL \
https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip \
-o /tmp/protoc/protoc.zip && \
cd /tmp/protoc && \
unzip protoc.zip && \
mv /tmp/protoc/include /usr/local/include
RUN mkdir -p /tmp/prototool
COPY go.mod go.sum /tmp/prototool/
RUN cd /tmp/prototool && go mod download
COPY cmd /tmp/prototool/cmd
COPY internal /tmp/prototool/internal
RUN cd /tmp/prototool && \
go install ./cmd/prototool && \
mv /go/bin/prototool /usr/local/bin/prototool
RUN upx --lzma /usr/local/bin/*
FROM alpine:edge
WORKDIR /work
ENV \
PROTOTOOL_PROTOC_BIN_PATH=/usr/bin/protoc \
PROTOTOOL_PROTOC_WKT_PATH=/usr/include \
GRPC_VERSION=1.21.3 \
PROTOBUF_VERSION=3.8.0 \
ALPINE_GRPC_VERSION_SUFFIX=r0 \
ALPINE_PROTOBUF_VERSION_SUFFIX=r0
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \
apk add --update --no-cache bash curl git grpc=${GRPC_VERSION}-${ALPINE_GRPC_VERSION_SUFFIX} protobuf=${PROTOBUF_VERSION}-${ALPINE_PROTOBUF_VERSION_SUFFIX} && \
rm -rf /var/cache/apk/*
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/include /usr/include
ENV GOGO_PROTOBUF_VERSION=1.2.1 \
GOLANG_PROTOBUF_VERSION=1.3.1 \
GRPC_GATEWAY_VERSION=1.8.5 \
GRPC_WEB_VERSION=1.0.4 \
TWIRP_VERSION=5.7.0 \
YARPC_VERSION=1.37.3