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: Add M1/ARM support for the test suite #516

Merged
merged 2 commits into from
Feb 27, 2022
Merged

fix: Add M1/ARM support for the test suite #516

merged 2 commits into from
Feb 27, 2022

Conversation

fizx
Copy link
Collaborator

@fizx fizx commented Feb 18, 2022

Fixes #515

Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @fizx ! Just a few questions on whether we could avoid another docker-compose file, but thanks for proactively tackling this!

context: .
dockerfile: "protoc.Dockerfile"
args:
- "ARCH=aarch_64"
Copy link
Owner

Choose a reason for hiding this comment

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

Hm, could we avoid a separate docker-compose.aarch64.yml and instead do something like ARCH=${ARCH:-x86_64} and pass in ARCH from aliases.sh?

@@ -1,10 +1,11 @@
# Docker image for protoc
FROM node:17-alpine3.14
Copy link
Owner

Choose a reason for hiding this comment

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

Fwiw I think we could also make this:

FROM --platform=linux/amd64 node:17-alpine3.13

Which would tell docker to just always run this as x86, even on M1s...

I think I slightly prefer that for simplicity, b/c this is meant as just a helper to execute protoc and so I don't think the perf overhead of emulating the x86 on an M1 would be a big deal/afaiu.

@boukeversteegh do you have any preference on which approach?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@stephenh please see my reply below. reply-by-mail doesn't seem to work as well

Copy link
Owner

Choose a reason for hiding this comment

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

Ah yep! I saw it, was just deferring to @fizx ; I guess specifically I'd like to avoid introducing a 2nd docker-compose.yml, so Kyle I think it's up to you if you'd like to either:

  • Update the current docker-compose.yml to take a $ARCH-type arg, or
  • Update the FROM to just always use --platform=linux/amd64

Fwiw here's a snippet of how we use a "sometimes-set-but-default-in-case" build arg in one of our docker-compose.ymls:

  db:
    build:
      context: .
      dockerfile: ./db.dockerfile
      args:
        TEST_PARALLELISM: ${TEST_PARALLELISM:-8}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Specifying architectures in the FROM line has been a source of much pain for me when porting other code to M1/ARM. I hope the updated solution is simple enough.

Copy link
Owner

Choose a reason for hiding this comment

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

@fizx ah sure! I just know that it's a thing (pinning an architecture in FROM); I haven't really used it personally / don't own an M1, so happy to defer since that's been a source of issues.

The ARCH build arg looks great, thanks!

@boukeversteegh
Copy link
Collaborator

boukeversteegh commented Feb 19, 2022 via email

@fizx
Copy link
Collaborator Author

fizx commented Feb 27, 2022

On my M1, the dockerfile now builds, and yarn build:test now works. Code should be cleaner too.

Building protoc
[+] Building 2.0s (13/13) FINISHED                                                                   
 => [internal] load build definition from protoc.Dockerfile                                     0.4s
 => => transferring dockerfile: 557B                                                            0.0s
 => [internal] load .dockerignore                                                               0.6s
 => => transferring context: 2B                                                                 0.0s
 => [internal] load metadata for docker.io/library/node:17-alpine3.14                           0.0s
 => [1/8] FROM docker.io/library/node:17-alpine3.14                                             0.0s
 => https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/protoc-3.19.1-linux-  0.7s
 => CACHED [2/8] RUN apk add bash                                                               0.0s
 => CACHED [3/8] RUN apk add gcompat                                                            0.0s
 => CACHED [4/8] ADD https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/pro  0.0s
 => CACHED [5/8] RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc   0.0s
 => CACHED [6/8] RUN ln -s /usr/local/lib/protoc/bin/protoc /usr/local/bin/protoc               0.0s
 => CACHED [7/8] RUN protoc --version                                                           0.0s
 => CACHED [8/8] WORKDIR /ts-proto/integration                                                  0.0s
 => exporting to image                                                                          0.5s
 => => exporting layers                                                                         0.0s
 => => writing image sha256:50522db9a36a653bc28e715475a618ebb3df240173187bb43cf3499936d81384    0.0s
 => => naming to docker.io/library/ts-proto_protoc                                              0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

@stephenh stephenh merged commit 7cf5625 into stephenh:main Feb 27, 2022
stephenh pushed a commit that referenced this pull request Feb 27, 2022
## [1.106.2](v1.106.1...v1.106.2) (2022-02-27)

### Bug Fixes

* Add M1/ARM support for the test suite ([#516](#516)) ([7cf5625](7cf5625))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.106.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker image doesn't build on M1
3 participants