Skip to content

Commit 0dd85a2

Browse files
committed
Fix proto gen
1 parent 19c4a7d commit 0dd85a2

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

hack/gen.Dockerfile

+13-18
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,18 @@
22

33
ARG GO_VERSION="1.19"
44
ARG 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
179
ARG PROTOC_VERSION
10+
ARG TARGETOS
11+
ARG TARGETARCH
1812
RUN <<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
2417
EOT
2518
WORKDIR /src
2619

@@ -30,15 +23,17 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3023
go mod download
3124

3225
FROM 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

3732
FROM tools AS generate
3833
RUN --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
4439
EOT

tools.go

-8
This file was deleted.

tools/tools.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build tools
2+
// +build tools
3+
4+
// Package tools tracks dependencies on binaries not referenced in this codebase.
5+
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
6+
package tools
7+
8+
import (
9+
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
10+
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
11+
)

0 commit comments

Comments
 (0)