Skip to content

Commit

Permalink
hack: update proto generators for arm64
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Jun 7, 2021
1 parent 229427f commit b247d6e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
16 changes: 11 additions & 5 deletions hack/dockerfiles/generated-files.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ ARG GOGO_VERSION=v1.3.2
RUN apt-get update && apt-get --no-install-recommends install -y \
unzip \
&& true
RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local

ARG TARGETOS TARGETARCH
RUN set -e; \
if [ "$TARGETARCH" = "amd64" ]; then TARGETARCH=x86_64; fi; \
if [ "$TARGETARCH" = "arm64" ]; then TARGETARCH=aarch_64; fi; \
wget -q https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${TARGETOS}-${TARGETARCH}.zip && unzip protoc-${PROTOC_VERSION}-${TARGETOS}-${TARGETARCH}.zip -d /usr/local

RUN git clone https://github.com/gogo/protobuf.git /go/src/github.com/gogo/protobuf \
&& cd /go/src/github.com/gogo/protobuf \
Expand All @@ -30,16 +35,17 @@ WORKDIR /go/src/github.com/moby/buildkit
# export`.
FROM gobuild-base AS generated
RUN mkdir /generated-files
RUN --mount=target=/tmp/src \
RUN --mount=target=/tmp/src env && \
cp -r /tmp/src/. . && \
git add -A && \
go generate ./... && \
go generate -mod=vendor -v ./... && \
git ls-files -m --others -- **/*.pb.go | tar -cf - --files-from - | tar -C /generated-files -xf -

FROM scratch AS update
COPY --from=generated /generated-files /generated-files

FROM gobuild-base AS validate
RUN --mount=target=/tmp/src \
ARG PROTOBUF_VERSION=
RUN --mount=target=/tmp/src env && \
cp -r /tmp/src/. . && \
go generate ./... && git diff && ./hack/validate-generated-files check
go generate -mod=vendor ./... -v && git diff && ./hack/validate-generated-files check
14 changes: 14 additions & 0 deletions hack/shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
function clean() {
docker rmi $(cat $iidfile)
}
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
DOCKER_BUILDKIT=1 docker build --iidfile $iidfile --target dev-env .
#DOCKER_BUILDKIT=1 docker build --iidfile $iidfile -f ./hack/dockerfiles/test.buildkit.Dockerfile --target dev-env .
trap clean EXIT
SSH=
if [ -n "$MOUNT_SSH_AUTH_SOCK" ]; then
SSH="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"
fi
docker run $SSH -it --privileged -v /tmp --net=host --rm -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry $(cat $iidfile)
5 changes: 3 additions & 2 deletions hack/update-generated-files
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
set -eu

gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' go.mod)
protobuf_version=$(awk '$3 == "github.com/golang/protobuf" { print $4 }' go.mod)
# protobuf_version=$(awk '$3 == "github.com/golang/protobuf" { print $4 }' go.mod)
output=$(mktemp -d -t buildctl-output.XXXXXXXXXX)

buildxCmd build \
--target "update" \
--build-arg "GOGO_VERSION=$gogo_version" \
--build-arg "PROTOBUF_VERSION=$protobuf_version" \
--output "type=local,dest=$output" \
--file "./hack/dockerfiles/generated-files.Dockerfile" \
.

# --build-arg "PROTOBUF_VERSION=$protobuf_version" \

cp -R "$output/generated-files/" .
rm -rf $output

0 comments on commit b247d6e

Please sign in to comment.