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

ci: add support for linux-arm64 build #1214

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
611f66b
feat: support building on arm64 arch
strophy Mar 13, 2022
03f7631
chore: update actions to use buildx
strophy Mar 13, 2022
c3d5fcc
fix: syntax error
strophy Mar 13, 2022
d20df49
chore: force multiarch build in ci
strophy Mar 13, 2022
e2a8c75
fix: split up target.platform
strophy Mar 13, 2022
8208229
chore: set array
strophy Mar 13, 2022
927736e
ci: enable qemu
strophy Mar 13, 2022
0e5f3e6
ci: try building for arm only
strophy Mar 13, 2022
7504f0d
chore: update google-closure deps
strophy Mar 14, 2022
605f574
chore: bump protobuf version to match prereqs
strophy Mar 14, 2022
c93a7f3
chore: change docker repo owner
strophy Mar 14, 2022
46cd321
chore: remove bazel version
strophy Mar 14, 2022
f7e6989
chore: change docker repo owner
strophy Mar 14, 2022
26cbde8
chore: remove platform specification
strophy Mar 14, 2022
46a7f0b
chore: try building without bake
strophy Mar 14, 2022
2fa7291
fix: invalid syntax
strophy Mar 14, 2022
2e3b22f
chore: don't load multiarch images
strophy Mar 14, 2022
73bf94e
chore: enable cache
strophy Mar 14, 2022
175dfc5
chore: bump underlying image versions
strophy Mar 14, 2022
7e7ee99
chore: reset qemu
strophy Mar 14, 2022
f9ee704
chore: copy arm64 binaries and login dockerhub
strophy Mar 15, 2022
5ff797f
chore: try to specify image tag
strophy Mar 15, 2022
764d23f
chore: revert to grpcweb org and tag latest
strophy Mar 15, 2022
8bb73b8
chore: rename variable in case statement
strophy Mar 16, 2022
dc05c39
chore: bump github action versions
strophy May 11, 2022
93f2c1e
refactor: use buildx bake hcl instead of compose
strophy May 11, 2022
61c715f
fix: java.lang.IncompatibleClassChangeError: Class does not implemen…
strophy May 11, 2022
3f7fc65
chore: try to load images after build
strophy May 12, 2022
04bedb6
feat: run multiarch build in matrix
strophy May 12, 2022
e58e92b
chore: debug vars
strophy May 12, 2022
0205739
fix: invalid variable substitution syntax
strophy May 12, 2022
0a16573
fix: both builds fail if one build fails
strophy May 12, 2022
b375768
fix: typo
strophy May 12, 2022
f906868
feat: implement buildkit gha cache
strophy May 12, 2022
015c182
fix: invalid variable substitution syntax
strophy May 12, 2022
36781de
fix: unknown flag: --cache-from
strophy May 12, 2022
cc73353
chore: remove debug output
strophy May 12, 2022
79f3e37
fix: cache miss with type=gha
strophy May 12, 2022
ebc5de8
chore: add tmate to debug bazel server terminated abruptly
strophy May 12, 2022
72b45c8
fix: bazel server terminated abruptly
strophy May 12, 2022
daee554
fix: try to reduce bazel jobs again
strophy May 12, 2022
2b9437a
chore: revert jobs=1
strophy May 15, 2022
1218cd5
chore: remove tmate debug access
strophy May 15, 2022
af7b7be
refactor: arm64 build in separate workflow
strophy May 17, 2022
b719fe8
chore: revert unnecessarily bumped closure js deps
strophy May 17, 2022
0abe741
chore: update node_interop_server base image
strophy May 17, 2022
74957f6
Merge remote-tracking branch 'upstream/master' into multiarch
strophy Jun 8, 2022
d8be410
fix: remove unnecessary bazel workaround
strophy Jun 8, 2022
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
66 changes: 58 additions & 8 deletions .github/workflows/make-plugin-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,72 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
archstring: x86_64
- arch: arm64
archstring: arm64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2

# Temporary fix for https://github.com/bazelbuild/bazel/issues/11379
- name: Reset QEMU
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ matrix.arch }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-buildx-

- name: Build plugin docker image
run: docker-compose build prereqs protoc-plugin
run: |
docker buildx bake -f release.hcl release \
--set *.platform=linux/${{ matrix.arch }} \
--set *.cache-from=type=local,src=/tmp/.buildx-cache \
--set *.cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new \
--load

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

- name: Copy binary from Docker image
run: |
docker cp $(docker create grpcweb/protoc-plugin):/github/grpc-web/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64
docker cp $(docker create --platform linux/${{ matrix.arch }} grpcweb/protoc-plugin):/github/grpc-web/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-${{ matrix.archstring }}

- name: gen sha256
run: |
openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256 \
protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64
- name: verify sha256
run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256
openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-${{ matrix.archstring }}.sha256 \
protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-${{ matrix.archstring }}

- name: verify sha256 x86_64
run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-${{ matrix.archstring }}.sha256

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: plugin
path: protoc-gen-grpc-web*


- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
31 changes: 16 additions & 15 deletions net/grpc/gateway/docker/prereqs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
# Stage 1: Fetch binaries
######################################
# node:... Docker image is based on buildpack-deps:stretch
FROM buildpack-deps:stretch AS prepare
FROM buildpack-deps:bullseye AS prepare
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made to match base image versions with the requirement to use node16:bullseye below


ARG BUILDIFIER_VERSION=1.0.0
ARG BUILDIFIER_VERSION=5.1.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is required because Buildifier 1.0.0 does not exist for arm64

ARG PROTOBUF_VERSION=3.19.4
ARG TARGETARCH

RUN apt-get -qq update && apt-get -qq install -y curl unzip

WORKDIR /tmp

RUN curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/\
protoc-$PROTOBUF_VERSION-linux-x86_64.zip -o protoc.zip && \
RUN case $TARGETARCH in arm64) arch="aarch_64"; ;; amd64) arch="x86_64"; ;; *) echo "ERROR: Machine type $TARGETARCH not supported."; ;; esac && \
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/\
protoc-$PROTOBUF_VERSION-linux-$arch.zip -o protoc.zip && \
unzip -qq protoc.zip && \
cp ./bin/protoc /usr/local/bin/protoc

RUN wget -nv -O buildifier \
https://github.com/bazelbuild/buildtools/releases/download/$BUILDIFIER_VERSION/buildifier && \
https://github.com/bazelbuild/buildtools/releases/download/$BUILDIFIER_VERSION/buildifier-linux-$TARGETARCH && \
chmod +x ./buildifier && \
cp ./buildifier /usr/local/bin/buildifier

Expand All @@ -49,10 +51,11 @@ RUN ./scripts/init_submodules.sh
######################################
# Stage 2: Copy source files and build
######################################
FROM node:12.22.6-stretch AS copy-and-build
FROM node:16-bullseye AS copy-and-build
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change prevents the following error under arm64 when running the closure compiler as follows:

#0 159.1 /github/grpc-web/packages/grpc-web/node_modules/.bin/google-closure-compiler --js=exports.js --js=../../javascript --js=node_modules/google-closure-library --entry_point=grpc.web.Exports --externs=externs.js --dependency_mode=PRUNE --compilation_level=ADVANCED_OPTIMIZATIONS --generate_exports --export_local_property_definitions --js_output_file=index.js
#0 179.0 npm ERR! code ENOENT
#0 179.0 npm ERR! syscall access
#0 179.0 npm ERR! path /github/grpc-web/packages/grpc-web/node_modules/grpc-web.js
#0 179.1 npm ERR! errno -2
#0 179.1 npm ERR! enoent ENOENT: no such file or directory, access '/github/grpc-web/packages/grpc-web/node_modules/grpc-web.js'
#0 179.1 npm ERR! enoent This is related to npm not being able to find a file.
#0 179.1 npm ERR! enoent 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha thanks for the context!

Do you mind replacing all 12.22.6 references in this repo to the same node version tho (there are 3 files afaict)?

Ideally to a more specific dot release to ensure our test here will always be running the same node version as the node server.


ARG MAKEFLAGS=-j8
ARG BAZEL_VERSION=4.1.0
ARG BAZELISK_VERSION=1.11.0
ARG TARGETARCH

RUN mkdir -p /var/www/html/dist
RUN echo "\nloglevel=error\n" >> $HOME/.npmrc
Expand All @@ -61,12 +64,10 @@ COPY --from=prepare /usr/local/bin/protoc /usr/local/bin/
COPY --from=prepare /usr/local/bin/buildifier /usr/local/bin/
COPY --from=prepare /github/grpc-web/third_party /github/grpc-web/third_party

RUN wget -nv -O bazel-installer.sh \
https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/\
bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
chmod +x ./bazel-installer.sh && \
./bazel-installer.sh && \
rm ./bazel-installer.sh
RUN wget -nv -O /usr/local/bin/bazelisk \
https://github.com/bazelbuild/bazelisk/releases/download/v$BAZELISK_VERSION/bazelisk-linux-$TARGETARCH && \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of bazelisk is required, since bazel-$BAZEL_VERSION-installer-linux-$arch does not exist for arm64

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!

May i ask you a favor to list out all the dependency updates you've made in this PR in a bullet-point summary? (Feel free to mention all other notable changes you made as well!)

chmod +x /usr/local/bin/bazelisk && \
bazelisk

WORKDIR /github/grpc-web

Expand All @@ -75,8 +76,8 @@ WORKDIR /github/grpc-web
COPY ./WORKSPACE ./WORKSPACE
COPY ./javascript/net/grpc/web/generator javascript/net/grpc/web/generator

RUN bazel build javascript/net/grpc/web/generator:protoc-gen-grpc-web && \
cp $(bazel info bazel-genfiles)/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
RUN bazelisk build javascript/net/grpc/web/generator:protoc-gen-grpc-web && \
cp $(bazelisk info bazel-genfiles)/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
/usr/local/bin/protoc-gen-grpc-web

COPY ./javascript ./javascript
Expand Down
8 changes: 4 additions & 4 deletions packages/grpc-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"devDependencies": {
"@types/google-protobuf": "~3.7.0",
"command-exists": "~1.2.8",
"google-closure-compiler": "~20200224.0.0",
"google-closure-deps": "~20210601.0.0",
"google-closure-library": "~20210808.0.0",
"google-protobuf": "~3.14.0",
"google-closure-compiler": "^20220301.0.0",
"google-closure-deps": "^20220202.0.0",
"google-closure-library": "^20220202.0.0",
"google-protobuf": "~3.19.4",
strophy marked this conversation as resolved.
Show resolved Hide resolved
"gulp": "~4.0.2",
"gulp-connect": "~5.7.0",
"gulp-eval": "~1.0.0",
Expand Down
15 changes: 15 additions & 0 deletions release.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
group "release" {
strophy marked this conversation as resolved.
Show resolved Hide resolved
targets = ["prereqs", "protoc-plugin"]
}

target "prereqs" {
dockerfile = "./net/grpc/gateway/docker/prereqs/Dockerfile"
}

target "protoc-plugin" {
dockerfile = "./net/grpc/gateway/docker/protoc_plugin/Dockerfile"
tags = ["docker.io/grpcweb/protoc-plugin"]
contexts = {
"grpcweb/prereqs" = "target:prereqs"
}
}