Building docker image with maven and dependency in corporate nexus repo with authentication

  build, docker, java, maven, nexus

I’m trying to use a docker image with maven to build my sources.
The project needs a dependency which is stored on our corporate authenticated nexus.
I’ve defined the repository in pom.xml but since the Nexus repo is authenticated I don’t know where to provide the credentials.
If the build was local i would use settings.xml but given I wanna do this in the image build I can find a way to do this.

The dockerfile is like this:

FROM diamol/maven AS builder

WORKDIR D:/wsEmy/myproject/src/
COPY pom.xml .
RUN mvn -B dependency:go-offline

COPY . .
RUN mvn package

# app
FROM diamol/openjdk

COPY --from=builder D:/wsEmy/myproject/target/myproject.jar .
COPY --from=builder D:/wsEmy/myproject/confExt/ .

ENTRYPOINT ["java", "-jar", "/app/myproject.jar --com.led.appconf="/app"]

Source: Docker Questions