In my maven pom file I have some dependencies which are our own jar files from other projects which are not in repository.We have used 'system' scoped dependencies like
<dependency>
<groupId>efaadmin</groupId>
<artifactId>efaadmin</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>
${basedir}\src\main\webapp\WEB-INF\lib\efaadmin.jar
</systemPath>
</dependency>
Now when writing Dockerfile these dependencies have become our stumbling block.
#
# Build stage
#
FROM maven:3.6.1-jdk-8-slim AS BUILD
COPY src /home/app/src
COPY pom.xml /home/app
COPY jars/*.jar /home/app/jars/
RUN mvn -f /home/app/pom.xml
#
# Package stage
#
FROM tomcat:7.0-jdk8-openjdk-slim
ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
COPY --from=build /home/app/target/DrySign.war $CATALINA_HOME/webapps/
COPY --from=build /home/app/target/jars/* $CATALINA_HOME/webapps/xxxxx/WEB-INF/lib/
EXPOSE 8080
CMD ["catalina.sh", "run"]
But docker is complaining:
'dependencies.dependency.systemPath' for efaadmin:efaadmin:jar must specify an absolute path but is ./jars/efaadmin.jar
How to deal with this?
This does not look like an issue with Docker, it looks like an issue with Maven. Maven requires an absolute path for system scope dependencies. You can test this is the case by commenting out all the lines of your Dockerfile below
By the way, why are you using backslashes not forward slashes for your
systemPath
? Your Maven system scoped dependencies are being interpreted as relative paths, not absolute paths. When you fix this, your build should work as intended.I can now build the Dockerfile. Here is my revised Dockerfile: