0

I have a Maven project that creates several Maven artefacts, one of these Maven project also creates a Docker image.

Now my problem is, it is no problem to get standard dependencies that lies in for ex in Maven Central (local Nexus may be) with curl, but how I am going a previous artefact created in Maven build....

My first idea was naturally to load it from local repository like

ADD /Volumes/D/localrepo/org.test.artefact/1.0-SNAPSHOT/artefact-1.0-SNAPSHOT.jar .

but off course this does not work because it is not under Docker context...

I don't want to do relative path tricks because I don't want that thing gets broken during a refactoring. Later stage in the project, artefacts will most probably be in company Nexus, it will be less of a problem but at this stage I don't have this luxury.

So how do you deal with such a problem?

Nicola Ben
  • 10,615
  • 8
  • 41
  • 65
posthumecaver
  • 1,584
  • 4
  • 16
  • 29
  • a) copy the jar to your local context prior to building the image b) set your docker context to the directory where the jar is built c) add a mount to your build directory if you're not on Windows (symlinks AFAIK are not yet supported as a source for ADD/COPY by Docker) - https://stackoverflow.com/a/27075486/4494577 – jannis Jun 26 '18 at 08:06
  • Well, thx for the tip, I choose to copy artefact with mvn dependency:copy, this way I didn't have to have a reference to hard copy operation.... – posthumecaver Jun 27 '18 at 07:30
  • You may want to check out [docker-maven-plugin](https://github.com/spotify/docker-maven-plugin), it may help you automate this. – jannis Jun 27 '18 at 07:50

0 Answers0