Multi Module Maven Project and Docker: Cannot find artifact?

  dependencies, docker, java, maven, pom.xml

I have the following multi-stage dockerfile that attempts to copy each module of my multi-module java maven project and build my ear file using mvn clean install.

dockerfile:

# Copy files from local to maven image and build ear
FROM maven:3.5-jdk-8 AS build  
COPY module1 /usr/src/app/src  
COPY module2 /usr/src/app/src  
COPY module3 /usr/src/app/src  
COPY pom.xml /usr/src/app  
RUN mvn -f /usr/src/app/pom.xml clean install

# Create server image + rest of docker file (working ok)

The error that I am getting is as follows:

Step 8/20 : RUN mvn -f /usr/src/app/pom.xml clean install
 ---> Running in cf9d8c1ef9ed
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.company.web:api:21.01-SNAPSHOT: Could not find artifact com.company.parent:jee6:pom:1.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 8, column 10
 @
[ERROR] The build could not read 1 project -> [Help 1]

The section in the pom.xml that corresponds to this error:

<parent>
<groupId>com.company.parent</groupId>
<artifactId>jee6</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>

I assume this issue because when trying to run the command in the maven docker image it cannot see my local .m2 folder? And the dependency that it is looking for is a private dependency on my local machine.

Would also copying my maven settings.xml help?

How can I resolve this? I do not want someone to have to have Maven installed on their machine in order to run this dockerfile.

Source: Docker Questions

LEAVE A COMMENT