War file not showing in docker image?

  docker, heroku, java, maven, wildfly

I tried deploying my docker image, which uses maven to package the war file, onto Heroku, but I keep getting an error. Here’s what I have in my dockerfile:

FROM maven:3.6.0-jdk-11-slim AS BUILD
COPY . /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml clean package

FROM jboss/wildfly:21.0.2.Final
COPY --from=BUILD /usr/src/app/Web-Service/target/web-service-1.0-SNAPSHOT.war /opt/jboss/wildfly/standalone/deployments/web-service.war
EXPOSE 8080 9990 8009
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0", "-c", "standalone.xml"]

And here’s the error I’ve been getting when trying to deploy the branch to heroku:

Step 5/7 : COPY --from=BUILD /usr/src/app/Web-Service/target/web-service-1.0-SNAPSHOT.war /opt/jboss/wildfly/standalone/deployments/web-service.war
COPY failed: stat /var/lib/docker/overlay/1b8b67fda67452e80ae9b7bb1cce52a8c8494ae3924ad7d498d03702947e2e4d/merged/usr/src/app/Web-Service/target/web-service-1.0-SNAPSHOT.war: no such file or directory

After building the war file using the mvn command, I still can’t access it with COPY –from=BUILD. Does anyone have any idea how I would be able to access it? Or how I can build the war file and add it to:

/opt/jboss/wildfly/standalone/deployments/

Or is there a better way of doing this? I tried following this guide for Docker multistage builds, but got the same error:
https://www.javacodegeeks.com/2017/04/creating-smaller-java-image-using-docker-multi-stage-build.html

Any help would be really appreciated!

Source: Docker Questions

LEAVE A COMMENT