I think the core issue here is the JDK installed isn’t compatible with the ARM architecture. So how does the image install the JDK? Looking at the image layers in the latest (at time of writing) FaunaDB Docker image the 9th layer seems to install the JDK. There is a piece of code that is interesting:
arch = "$(dpkg --print-architecture)";
case "$arch" in 'amd64')
downloadUrl = 'https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_11.0.12_7.tar.gz';
;;
'arm64')
downloadUrl = 'https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_aarch64_linux_11.0.12_7.tar.gz';
;;
*)
echo > &2 "error: unsupported architecture: '$arch'";
exit 1
;;
esac;
It looks like there is already support for ARM 64-bit architectures (and has been since 2.6.2). If dpkg --print-architecture
returns 'arm64'
then the JDK that supports ARM is downloaded and installed. So why doesn’t that happen?
I shelled into a Docker container running Fauna and ran dpkg --print-architecture
on a MacBook Pro with an M1 chip. It returned amd64
. This isn’t necessarily surprising given we already know an AMD compatible JDK was installed. Also we know Docker can emulate AMD machines.
I then tried to force the platform to arm64
by running docker run
with the platform
flag set to linux/arm64
. This yielded a warning and error:
WARNING: image with reference fauna/faunadb was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64
docker: Error response from daemon: image with reference fauna/faunadb was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64.
It seems the image specifies the platform to be linux/amd64
. Again, not a surprise, as far as I know that’s the default. So we need a linux/arm64
build.
As far as I can tell, there is nothing preventing this image to be ARM compatible given there is already architecture detection built-in. I think this means all Fauna needs to do is build images for ARM and this, as far as I know, could be a simple as using BuildKit with Docker and specifying the platforms. If Fauna builds images by running docker build
then they’ll need to change that to docker buildx build --platform linux/amd64,linux/arm64
.
I’ll caveat all the above that it’s just based on what I can observe through any references I’ve linked. It may be more complicated than I realise but if the Fauna team hasn’t done any investigation on this, hopefully it’ll kickstart things and hopefully it’ll be as simple as the above and they can implement soon.
Second caveat, I’m not sure the ARM64 JDK from AdoptOpenJDK is Mac compatible. When I set up my M1 Mac I did come across an issue where there weren’t JDKs from AdoptOpenJDK that supported M1 Macs and I had to use a build from Azul. As far as I’m aware this hasn’t changed but it may have and I’m wrong.
With M1 Macs being demonstrably more performant, more and more developers will move to them and the tools that don’t move to support this are massive blockers. I wish I could give a bigger +1 to this request.