rajch / weave

Simple, resilient multi-host containers networking and more.
https://rajch.github.io/weave/
Apache License 2.0
37 stars 6 forks source link

Reweave (build on aarch64/macos with Rancher + Buildx) #1

Closed kingdonb closed 1 year ago

kingdonb commented 1 year ago

I needed these changes to make it build successfully on my macbook M1.

I was not certain about these changes. I haven't had a time to test them fully, but I struggled for a few minutes to be sure the build would work. WDYT, does this look correct?

kingdonb commented 1 year ago

I tried using TARGETPLATFORM but it didn't seem to work. I guess that TARGETARCH worked because you had already:

ARG TARGETARCH

If that makes sense then probably either would have worked, and I'd guess this version is fine. (Still intend to test...)

rajch commented 1 year ago

Strange. As per the Dockerfile reference, specifically here, both TARGETPLATFORM and TARGETARCH should have worked. I re-declared TARGETARCH inside stage 2 so that I could pass to the Makefile inside.

From everything I have read, adding --platform=${TARGETPLATFORM} is not needed, because that is the default behaviour. Maybe that's why --platform=linux/${TARGETARCH} worked.

Anyway, this looks good to me. Let's keep it.

kingdonb commented 1 year ago

Yeah either would work but you can only use these variables in the Dockerfile if you declare them as an ARG, which exports them. They are builtins from BuildKit, so they will only be available if they are provided by BuildKit upstream (eg. not when running on a bare Docker engine with no BuildKit) and only if they are exported as an ARG.

I would probably add TARGETPLATFORM like BUILDPLATFORM that was already defined as an ARG. Then we don't need to have an awkward like --platform=linux/${TARGETARCH} – I think that TARGETPLATFORM will always say linux, even on a MacOS host. It just needs to be exported before it is used. (That was my main confusion here. I think that some platform directives may be dependent on whether you have used --platform before in any earlier stage in this Dockerfile! I am not sure exactly. That, and I believe I may have also copied you the wrong error message before...)

I'll send you another pull request after I get a chance to finally test the image for arm64 🎉 I have the strategic reserve of some CM3 boards for a Turing Pi that should work with this.

Thanks so much for doing all this!