Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proto gen #720

Merged
merged 1 commit into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions hack/gen.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

ARG GO_VERSION="1.19"
ARG PROTOC_VERSION="3.17.3"
ARG GLIBC_VERSION="2.33-r0"

FROM golang:${GO_VERSION}-alpine AS base
ARG GLIBC_VERSION
RUN apk add --no-cache curl file git unzip
RUN <<EOT
set -e
curl -sSL "https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub" -o "/etc/apk/keys/sgerrand.rsa.pub"
curl -sSL "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" -o "glibc.apk"
apk add glibc.apk
rm /etc/apk/keys/sgerrand.rsa.pub glibc.apk
EOT
# protoc is dynamically linked to glibc so can't use alpine base
FROM golang:${GO_VERSION}-bullseye AS base
RUN apt-get update && apt-get --no-install-recommends install -y git unzip
ARG PROTOC_VERSION
ARG TARGETOS
ARG TARGETARCH
RUN <<EOT
set -e
curl -sSL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" -o "protoc.zip"
unzip "protoc.zip" -d "/usr/local"
protoc --version
rm "protoc.zip"
arch=$(echo $TARGETARCH | sed -e s/amd64/x86_64/ -e s/arm64/aarch_64/)
wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${TARGETOS}-${arch}.zip
unzip protoc-${PROTOC_VERSION}-${TARGETOS}-${arch}.zip -d /usr/local
EOT
WORKDIR /src

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

FROM vendored AS tools
RUN --mount=type=bind,target=.,rw \
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/go/pkg/mod \
go install -v $(sed -n -e 's|^\s*_\s*"\(.*\)".*$|\1| p' tools.go)
go install \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
google.golang.org/protobuf/cmd/protoc-gen-go

FROM tools AS generate
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/go/pkg/mod <<EOT
set -e
go generate ./...
go generate -v ./...
mkdir /out
cp -Rf pb /out
EOT
Expand Down
8 changes: 0 additions & 8 deletions tools.go

This file was deleted.

11 changes: 11 additions & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build tools
// +build tools

// Package tools tracks dependencies on binaries not referenced in this codebase.
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package tools

import (
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
)