Comments (6)
Nothing in /root/.m2 is persisted in the image, you would need to put the jars somewhere else
from docker-maven.
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.
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.
@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.
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.
.m2 is no longer a volume
from docker-maven.
Related Issues (20)
- Adding corretto-maven images based on Debian HOT 10
- Maven tag for JDK 20 HOT 3
- Errors running MavenCLI HOT 11
- 3.9.2 java 8 handshake_failure HOT 4
- Maven 3.9, unauthorized 401 when reaching MS AZURE repo with PAT HOT 6
- Please update bash in Alpine image to avoid error message HOT 1
- Latest images don't have ssh causing maven-release-plugin to fail HOT 10
- Could not create local repository at /home/user/.m2/repository
- Please add amazoncorretto + al2023 images HOT 2
- How to get 3.9.4 released? HOT 1
- Wrong docer example for eclipse-temurin-17 version? HOT 1
- amazoncorretto-11-debian ignores environment variables with a period HOT 1
- ETA on JDK 21 compatible image
- Corretto 21 + AL2023 HOT 5
- Add Eclipse Temurin 21 HOT 1
- /usr/local/bin/mvn-entrypoint.sh: 50: exec: 1: not found HOT 2
- maven: 3.6.3-openjdk-21 HOT 1
- Add Apache Maven 3.9.6
- Image maven:3.8.8 missing
- Publish image with semeru jdk 21 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-maven.