I have a Maven Java application that I am trying to dockerize. I have the following dockerfile so far, that I copied from this answer.
#
# Build stage
#
FROM maven:3.6.0-jdk-11-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean install
EXPOSE 8080 9990
COPY --from=build /usr/src/app/target/helloworld-1.0.0-SNAPSHOT.jar /opt/jboss/jboss-eap-6.2/standalone/deployments/
This would be fine if my application was a single module project, however because it is multi-module, I assume that I cannot just use COPY src /home/app/src
.
How can I change my dockerfile to account for my multi-module project?
I have tried the following:
#
# Build stage
#
FROM maven:3.6.0-jdk-11-slim AS build
COPY module1 /home/app
COPY module2 /home/app
COPY module3 /home/app
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean install
EXPOSE 8080 9990
COPY --from=build /usr/src/app/target/helloworld-1.0.0-SNAPSHOT.jar /opt/jboss/jboss-eap-6.2/standalone/deployments/
However this gives error at the mvn clean install
stage:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for myapp:21.01-SNAPSHOT: Could not find artifact jee6:pom:1.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 8, column 10
Note that jee6:pom:1.0.1-SNAPSHOT
is from my local m2 folder.