0

I'm setting up a pipeline for a java app. I can successfully build the app into a JAR, but I then want to create a docker container and add the JAR to that container.

My jar file is created at /drone/src/target/app.jar

However, when I try to ADD the jar during the container build stage, I get the following error...

ADD failed: stat /var/lib/docker/tmp/docker-builder947505275/app.jar: no such file or directory

How can I get my deploy stage to utilize the jar from the build stage?

Charles
  • 11
  • 1
    Can you provide more details of your Dockerfile, and project structure? The error message is telling you that the add is looking in a different directory than where your file is at. Without knowing more info as to how you have defined the statement as well as other pre-steps in the docker file, it is not possible to help with a solution. – Daileyo May 13 '21 at 22:59
  • The step that fails from the Dockerfile is the following... ADD target/app.jar app.jar When I build the container manually, I am just copying my jar into the container. Obviously, I don't think I want to edit my Dockerfile to make it specific to this drone pipeline, so I suspect there should be some way to configure drone to know how to find the correct file. – Charles May 14 '21 at 14:30
  • Is your dockerfile in the src directory? – Daileyo May 14 '21 at 19:40

1 Answers1

0

I ultimately resolved the problem by changing my approach.

Instead of having drone package the JAR in step 1 and then have drone build a container which would have the JAR added to it, I updated my Dockerfile to do the packaging of the JAR. So the pipeline now just has 1 stage but it achieves what I set out to do.

Charles
  • 11