Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Сache .m2 dependencies #141

Merged
merged 2 commits into from
Feb 5, 2025
Merged

Сache .m2 dependencies #141

merged 2 commits into from
Feb 5, 2025

Conversation

vlsi
Copy link
Contributor

@vlsi vlsi commented Feb 5, 2025

Previously, every docker build downloaded Maven dependencies on every build. This enables reuse .m2 folder across builds which significantly improves the build times.

Which problem is this PR solving?

Running docker build . takes time, and most of the time is spent on downloading Maven dependencies

Description of the changes

Mount /root/.m2 as a cache folder

How was this change tested?

Modify .java file, run docker build ..
After the fix, the output does not contain "downloading ..." messages.

Checklist

Previously, every docker build downloaded Maven dependencies on every build.
This enables reuse .m2 folder across builds which significantly improves the build times.

Signed-off-by: Vladimir Sitnikov <[email protected]>
@vlsi vlsi changed the title chore: cache .m2 dependencies Сache .m2 dependencies Feb 5, 2025
@@ -26,7 +26,7 @@ COPY .mvn $APP_HOME/.mvn
COPY mvnw $APP_HOME

WORKDIR $APP_HOME
RUN ./mvnw package -Dlicense.skip=true -DskipTests && rm -rf ~/.m2
RUN --mount=type=cache,target=/root/.m2 ./mvnw package -Dlicense.skip=true -DskipTests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does Maven know to look at root/.m2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out https://maven.apache.org/settings.html

localRepository: This value is the path of this build system's local repository. The default value is ${user.home}/.m2/repository

The username is root, thus /root/.m2

@yurishkuro yurishkuro enabled auto-merge (squash) February 5, 2025 19:26
@yurishkuro yurishkuro merged commit ffc9b2b into jaegertracing:main Feb 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants