Error invoking maven in Dockerfile dind building for ARM

Hi!
I’m trying to build a docker image for ARM. I do this using gitlab ci and docker in docker on gitlab.com.
It works for e.g. node parts, but when I get to invoking mvn in my Dockerfile it fails with this:
java.lang.ClassNotFoundException: org.apache.maven.cli.MavenCli

The same Dockerfile works without problem if I run in on an RPi.

I’ve tried the maven image for my maven build and also tried more plain java image and download maven. Same error.

I use these two lines to just test if it works.

RUN java -version # Outputs correct:

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9)
OpenJDK Server VM AdoptOpenJDK (build 15.0.1+9, mixed mode)

RUN mvn --version # Fails with above error

This is my gitlab-ci.yml

image: docker:stable
services:
  - name: docker:stable-dind
    command: ["--experimental"]

stages:
  - build
  - release

variables:
  DOCKER_HOST: tcp://docker:2375
  CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:test
  CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
  BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64
  TARGET_ARCH: linux/arm/v7

before_script:

build:
  stage: build
  script:
    - mkdir -p $HOME/.docker/cli-plugins/
    - wget -O $HOME/.docker/cli-plugins/docker-buildx $BUILDX_URL
    - chmod a+x $HOME/.docker/cli-plugins/docker-buildx
    - "echo -e '{\n  \"experimental\": \"enabled\"\n}' | tee $HOME/.docker/config.json"
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    - docker buildx create --use --driver docker-container --name mybuilder --platform=$TARGET_ARCH
    - docker buildx inspect --bootstrap
    - docker buildx build --platform=$TARGET_ARCH --pull -t $CONTAINER_TEST_IMAGE --push .

release-image:
  stage: release
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker pull $CONTAINER_TEST_IMAGE
    - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
    - docker push $CONTAINER_RELEASE_IMAGE
  only:
    - master

And this is my Dockerfile

# Build node
FROM node:15-slim AS node-builder

WORKDIR /app

COPY /src/main/webapp/package.json ./
COPY /src/main/webapp/yarn.lock ./

RUN yarn install

COPY /src/main/webapp/. .

RUN yarn run build

# Build maven
FROM maven:3-adoptopenjdk-15 as maven-builder

COPY pom.xml .

# RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve
COPY src ./src
COPY --from=node-builder /app/dist src/main/resources/static/
# RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package
RUN java -version
RUN mvn --version

I’m stumped and google isn’t in a helping mood. Just get hits about that error caused by incorrect maven installs with empty lib folders. That’s not the case here. Also some posts about proxies blocking maven from downloading it’s own deps. But I had no trouble downloading the maven binaries in the plain java image, still gave same error.

Any help/advice/hints would be greately appreciated.

All the best!
Relnah