Docker Community Forums

Share and learn in the Docker community.

Set up Maven in docker image and setting up M2_HOME env variable


(Sarojpanigrahy) #1

Hi,

We have a set up as follows:

  1. We have a webservice which processes the rules through KIE sessions.
  2. KIE spring integration is done so that the sessions are created during server start up.
  3. During server start up the application refers a remote repo during runtime from a remote repo not from local m2.[We have achieved this by having the custom settings.xml in the .m2 folder ]

Everything is working fine in my local windows i.e. the jars are downloaded runtime during server start up.

Now the requirement is to run the above set up in a docker.

I have tried to create a docker image with the following written in dockerfile,

FROM maven:3.3-jdk-8
EXPOSE 8080
ADD settings.xml /root/.m2/settings.xml

But when I start the container the application code tries to get the jar file from default maven repo i.e.

Unable to resolve artifact: demo:KieSessionFinal:pom:1.0 org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact demo:KieSessionFinal:pom:1.0 in central (http://repo1.maven.org/maven2/)
** at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(Defa**
ultArtifactResolver.java:444) ~[aether-impl-1.0.0.v20140518.jar:na]

Can anyone please help how do we
Set up the setting.xml in an dockerized environment so that it can read from the remote repo ?
Ideally maven looks for settings.xml in M2_HOME. So, where and how to place the settings.xml in the docker image or docker container ?

Regards
Saroj