Skip to content

Conversation

@andersonpem
Copy link
Contributor

Leverage architecture on build context

Considering the ubiquity of ARM64, now in Macbooks with M1 and M2, and future computers with Windows on ARM (10/11), having multiarch support is a must-have in the developer toolbelt. As an owner of the M1 MacBook Pro, I really feel the difference in performance when using a linux/arm64 based image. Especially with the latest Docker for Mac version.

In the cloud side, cheaper instances with ARM64 architecture are popping out all over the place, like the Amazon EC2 A1, for example.

I do use TheCodingMachine's project a lot, and I'm a great supporter for the project. I used to use it a lot in Brazil in many companies I worked for. Likewise, I decided to implement and test multiarch support.

I've tested all the versions on an ARM64 VM with Linux and Docker installed (With UTM, a very good QEMU GUI for M1 Mac) and all the images passed the test.

I've been using the linux/arm64 version of this image to work for more than a month and I could not find a single misbehavior.

Basically, the main change is that the binaries that were statically being pulled in an AMD64 version (like SuperCronic, Tini, or Blackfire) now use variables given by buildkit to determine which OS and Arch is being used and pulls the proper binary for the target OS.

This PR fixes/implements :

Test plan (required)

Have an ARM64 VM or configure buildkit to be able to build for ARM64.

# If no platform is specified, linux/amd64 will be assumed.

PHP_VERSION=<version> BRANCH=v4 VARIANT=<variant> PLATFORM=linux/arm64 BLACKFIRE_VERSION=<optional: defaults to 1> ./build-and-test.sh

Checklist

  • I followed the guidelines in CONTRIBUTING guide
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code

@andersonpem
Copy link
Contributor Author

In the CI/CD pipeline, now one can, in theory, buildx can accept more than one platform in the manifest for building and pushing, since the images are now configured to expect different OSes and architectures.
However, for building and testing locally, only a single platform can be specified at a time.

@mistraloz
Copy link
Collaborator

Ooooh nice ! Many thanks :)

@mistraloz
Copy link
Collaborator

Ok, missing some adjustement in CI/CD. I will try to test that next week.

This was referenced Jul 21, 2022
@mistraloz mistraloz merged commit bbb8ea0 into thecodingmachine:v4 Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants