22
33ARG GO_VERSION="1.19"
44ARG PROTOC_VERSION="3.17.3"
5- ARG GLIBC_VERSION="2.33-r0"
65
7- FROM golang:${GO_VERSION}-alpine AS base
8- ARG GLIBC_VERSION
9- RUN apk add --no-cache curl file git unzip
10- RUN <<EOT
11- set -e
12- curl -sSL "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" -o "/etc/apk/keys/sgerrand.rsa.pub"
13- curl -sSL "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" -o "glibc.apk"
14- apk add glibc.apk
15- rm /etc/apk/keys/sgerrand.rsa.pub glibc.apk
16- EOT
6+ # protoc is dynamically linked to glibc so can't use alpine base
7+ FROM golang:${GO_VERSION}-bullseye AS base
8+ RUN apt-get update && apt-get --no-install-recommends install -y git unzip
179ARG PROTOC_VERSION
10+ ARG TARGETOS
11+ ARG TARGETARCH
1812RUN <<EOT
1913 set -e
20- curl -sSL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" -o "protoc.zip"
21- unzip "protoc.zip" -d "/usr/local"
22- protoc --version
23- rm "protoc.zip"
14+ arch=$(echo $TARGETARCH | sed -e s/amd64/x86_64/ -e s/arm64/aarch_64/)
15+ wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${TARGETOS}-${arch}.zip
16+ unzip protoc-${PROTOC_VERSION}-${TARGETOS}-${arch}.zip -d /usr/local
2417EOT
2518WORKDIR /src
2619
@@ -30,15 +23,17 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3023 go mod download
3124
3225FROM vendored AS tools
33- RUN --mount=type=bind,target=.,rw \
26+ RUN --mount=type=bind,target=. \
3427 --mount=type=cache,target=/go/pkg/mod \
35- go install -v $(sed -n -e 's|^\s *_\s *"\( .*\) ".*$|\1 | p' tools.go)
28+ go install \
29+ google.golang.org/grpc/cmd/protoc-gen-go-grpc \
30+ google.golang.org/protobuf/cmd/protoc-gen-go
3631
3732FROM tools AS generate
3833RUN --mount=type=bind,target=.,rw \
3934 --mount=type=cache,target=/go/pkg/mod <<EOT
4035 set -e
41- go generate ./...
36+ go generate -v ./...
4237 mkdir /out
4338 cp -Rf pb /out
4439EOT
0 commit comments