Code Monkey home page Code Monkey logo

Comments (6)

carlossg avatar carlossg commented on May 18, 2024

Nothing in /root/.m2 is persisted in the image, you would need to put the jars somewhere else

from docker-maven.

doublebyte1 avatar doublebyte1 commented on May 18, 2024

Thanks for the quick reply. Based on what you said, this is what worked for me (maybe it can help others):

As the repository defined on settings.xml is only available on runtime, I have set it explicitly during my builds. Building the first project:

RUN mvn install -DskipTests -Drelax -gs /usr/share/maven/ref/settings-docker.xml

This has left the jars on /usr/share/maven/ref/repository, according to what is defined in settings.xml. Then I built the second project with the same flag:

RUN mvn install -DskipTests -Drelax -gs /usr/share/maven/ref/settings-docker.xml

And it found the dependencies on /usr/share/maven/ref/repository

from docker-maven.

MrSleazy avatar MrSleazy commented on May 18, 2024

Hi @doublebyte1, @carlossg. Thanks for both of your answers.

I am actually having a similar issue. How did you customize the contents of setting-docker.xml inside of your image?

I currently need to set up a proxy for maven so I am trying to set up the build on a CI with the following image (https://github.com/alirizasaral/Maven-with-Proxy). This works fine, but I have the issue that maven downloads all the dependencies from scratch without caching them inside the repository every time I run a build on the CI.

Should I not be using an image based on alpine to get the maven repository to work correctly, or am I missing something more fundamental?

from docker-maven.

cedricwalter avatar cedricwalter commented on May 18, 2024

@KevinSilvaQuintana

Add in your Dockerfile
COPY settings-docker.xml /usr/share/maven/ref/
in your docker directory, create a new file settings-docker.xml with content

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
  | https://maven.apache.org/xsd/settings-1.0.0.xsd">
  | <localRepository>/usr/share/maven/ref/repository</localRepository>
  | </settings>

use in all mvn command
RUN mvn install -DskipTests -Drelax -gs /usr/share/maven/ref/settings-docker.xml

run again a build with no-cache to avoid to reuse some step that were not creating dependency jar in new repository folder
sudo docker build --no-cache <yourdockerdirectory>

from docker-maven.

MrSleazy avatar MrSleazy commented on May 18, 2024

Hi @cedricwalter ,

I actually ended up finding a solution which I have outlined in this post:
https://stackoverflow.com/questions/33430487/how-to-use-gitlab-ci-to-build-a-java-maven-project

However, between that and your solution, I am not sure which is more 'clean'. Your approach is very simple and straight forward. However, I think that being able to centralize everything in the CI build file will allow for a more generic re-use for future projects. I'll give it a try though. 👍

from docker-maven.

carlossg avatar carlossg commented on May 18, 2024

.m2 is no longer a volume

from docker-maven.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.