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
efaadmin
efaadmin
system
1.0
${basedir}\src\main\webapp\WEB-INF\lib\efaadmin.jar
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
...
RUN mvn -f /home/app/pom.xml
# comment out everything below this, I think you'll still see the failure
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.