Trying to build a multi-arch elasticsearch image (linux/amd64 linux/arm64) for developers working on CirrusSearch I encountered the following error:
#12 [linux/arm64 2/5] RUN (getent group "1000" || groupadd -o -g "1000" -r "elasticsearch") && (getent passwd "1000" || useradd -l -o -m -d "/home/elasticsearch" -r -g "1000" -u "1000" "elasticsearch") && mkdir -p "/usr/share/elasticsearch" && chown "1000":"1000" "/usr/share/elasticsearch" && mkdir -p "/opt/lib" && chown "1000":"1000" "/opt/lib" #0 1.207 standard_init_linux.go:219: exec user process caused: exec format error #12 ERROR: process "/bin/sh -c (getent group \"$LIVES_GID\" || groupadd -o -g \"$LIVES_GID\" -r \"$LIVES_AS\") && (getent passwd \"$LIVES_UID\" || useradd -l -o -m -d \"/home/$LIVES_AS\" -r -g \"$LIVES_GID\" -u \"$LIVES_UID\" \"$LIVES_AS\") && mkdir -p \"/usr/share/elasticsearch\" && chown \"$LIVES_UID\":\"$LIVES_GID\" \"/usr/share/elasticsearch\" && mkdir -p \"/opt/lib\" && chown \"$LIVES_UID\":\"$LIVES_GID\" \"/opt/lib\"" did not complete successfully: exit code: 1 #11 [linux/amd64 2/5] RUN (getent group "1000" || groupadd -o -g "1000" -r "elasticsearch") && (getent passwd "1000" || useradd -l -o -m -d "/home/elasticsearch" -r -g "1000" -u "1000" "elasticsearch") && mkdir -p "/usr/share/elasticsearch" && chown "1000":"1000" "/usr/share/elasticsearch" && mkdir -p "/opt/lib" && chown "1000":"1000" "/opt/lib" #11 1.161 elasticsearch:x:1000: #11 1.164 elasticsearch:x:1000:1000::/usr/share/elasticsearch:/bin/bash #11 DONE 1.2s
which seems to suggest that the gitlab runner is not able to emulate the arm64 arch.
Full build: https://gitlab.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image/-/jobs/89862
Locally the arm64 does seem to be built properly with blubber using buildx and after installing tonistiigi/binfmt:
docker run --privileged --rm tonistiigi/binfmt --install all docker buildx build --platform=linux/arm64 --target devel --tag docker-registry.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image:mylocalbuild -f .pipeline/blubber.yaml .
Looking at others builds in gitlab I believe that it's possible to build an image for arm64 looking at blubber build-frontend but it's not clear to me how this has to be setup.
I know that there might be blockers further down the road with issues like T322453 but I believe that I'm hitting an issue earlier at the build stage.