How to build Docker multiarch image for native code

252 views Asked by At

I've been building some multiarch images for Java apps, based off someone else's multiarch base image which works fine, because the base image includes the right native Java version for the architecture. All I have to do is add my platform-agnostic JAR file and I have a multiarch image that works on my Windows laptop and on my rPi Kubernetes cluster.

Now though, I am experimenting with GraalVm and I would like to create a multiarch base image of my own that my projects will all use. This means I need to work out how to create a multiarch Docker image where different architectures require different installs. The amd64 Dockerfile needs the amd64 version of GraalVm to be installed and the arm Dockerfile needs the arm version of GraalVM.

I have used Dockerfile ARGs with --build-arg in the past to work out what URI to download for the GraalVm installer, but I am stuck on how to do this with 'buildx'.

It seems that every single demo/tutorial I watch uses a simple example where the files they add are not specific to the architecture. So they can just add them regardless of the platform being built for. How do people solve this problem? Is buildx not suitable for this problem?

The manifest approach seems much more appropriate for this problem (albeit more verbose) in that I can create an image for each architecture and then combine them, thus giving me the opportunity to build them differently. Is this just a constraint of the tooling? I'd rather do it with buildx if it can be done.

0

There are 0 answers