-
Notifications
You must be signed in to change notification settings - Fork 214
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
[discussion] run mvnd in docker #496
Comments
We currently have only a local, file-based daemon registry, so discovering a daemon running on a different host is not possible. Having some general service discovery mechanism sounds interesting. Have you thought of some specific protocol/implementation? |
Also, if the |
The daemon could be inside my build-container (that has other build-tooling i need as part of the mvn build). I just need to: (1) make sure it never shuts down, because it's a daemon |
I think @dcaillia could run both the daemon and the |
There is currently no easy way to start the daemon process directly. But it is not that hard to put together the necessary command. You could e.g. start the daemon via
You could then put a similar command to your dockerfile.
You could perhaps mount your whole home folder or whichever folder containing all your projects? Then you could do something like |
So mvnd has less potential on CI, because can‘t benifit from daemon, more suitable for local build and run proeject again and again, is it right? |
Indeed, mvnd was primarily designed as an interactive tool run by humans. |
On our CI pipelines, on a single build we launch mvn multiple times across jenkins stages, eg: lint, test, integration test, javadocs and so on, so I believe that we would benefit from mvnd on CI even though in that scenario, the definition of long-running daemon might be not so long.
Where container 1-4 calls would reuse the daemon launched by container 0. Would that be possible ? Is there other strategy that we could benefit from mvnd given our 'restriction' of launching mvn plugins on separate containers ? |
The existing network protocol between mvnd client and the daemon would work without any change even if daemon runs on a different host. What is missing is a discovery mechanism for the clients to find daemon(s) running on other hosts. Currently there is only a local file-based deamon registry implementation: the client looks into that file for existing daemons and the daemons write their busy/idle state and port there. So we need some new mechanism. |
Sounds perfect. That was exactly what I was hoping for 👍🏻 |
This would be extremely useful for us in the context of running this in k8s. We use the github actions ARC controller, so our runners spin up as pods in our cluster. I suppose I'm just commenting here because it's nice to daydream. Back to trying to figure out why my builds wont use the .m2 cache on my build container 🙃 |
Interesting ideas in this discussion... |
Yooooo I literally just stumbled upon this https://github.com/fbricon/mvn-cache-test https://maven.apache.org/extensions/maven-build-cache-extension/getting-started.html https://maven.apache.org/resolver/ https://maven.apache.org/extensions/maven-build-cache-extension/remote-cache.html This might solve my thing, but I wonder if there are working parts here that mvnd could piggyback on |
This would open doors for a lot of new use cases. Right now I use the plugin only during the deployment of the application, get the secrets and put to K8s secrets. it's nice to daydream 😄 |
@wallentx I think it is possible to use this cache extension with mvnd
But it does not address all the requirements listed in the discussion here. For instance, I suppose it will not be used for the below specifities of mvnd:
IMHO the way is to be able to use a remote centralized long running daemon from multiple mvnd clients, or externalize the cache of the daemon so it can be shared but that might be a bit more complex if the daemons sharing the same cache runs different plugins/tasks. |
I have tested this approach, but it seems the mvnd client does not necessarily use the already running deamon everytime, even if you run the same mvn commands exactly 😞 I have a project here where I run a container with a docker deamon as main process, and execute mvnd client by connecting to it via It never uses the main deamon already running on the container. Maybe I am missing something, or we need to implement a logic that is reproducible for clients that requires selecting specific deamons. |
@HomeOfTheWizard what is |
@ppalaga Thanks for pointing out. It is in "Busy" status. probably the reason why I can't reuse it.
Can those params play a role in the status of the deamon beeing "Busy" ? here is the full command of my Dockerfile
|
Yeah, the daemon starts in busy state so that the client that initiates its start can grab it by daemonId. Not sure what is the goal of your experiments? You just want to invoke the client inside the running container so that it connects to the main daemon?
Note that when starting the daemon in the container, you must use the same -Dmvnd.id=... as shown by If you want to run the client in a different process, then you may want to implement some new client options for connecting to a remote daemon. |
Actually, if your goal is just to invoke the client inside the running container, then you may start the daemon by simply |
My use case is the same as @dcaillia and @chicobento. The main goal of my experiment is to see if I can start a container with a deamon already running, and with a JIT cache already warmed up and the plugin classloaders already loaded, for the set of plugins I use in my project. But first I tried to see if I can connect to an already running deamon. Now the question is: |
JIT and classloader caching will only kick in when you build against the same daemon process repeatedly. A freshly started container will host a freshly started daemon with empty classloader caches and no code JIT-ed. Unless you want to experiment with CRaC or similar tech? I am not aware that anybody would ever tried that with Maven Daemon. It is a great use case and it would be very interesting to see how well it works. |
My question was actually: "is there a way to export/store the JIT and plugin classloaders cache, so we can override and reuse in a new daemon, just like the registry file." But I just realized by reading again the doc, that the daemon is a normal JVM so no AOT, the only GraalVM native process is the client, and all those cache of the daemon are in memory, so no way to persist it to be able to export and reuse. I will play around with CRaC and let know if that helps. Thanks for your help again. |
I have a docker image that contains a regular maven installation, jdk and other build tools.
I use it to run mvn (volume-mounting only my project sources and .m2) both during local development and on the build-server.
I like this because it makes sure my local builds are built exactly like on the build-server (which uses the same "build image"). The Dockerfile of my build image is also important as it completely defines the build environment and tools.
I'm wondering how to get the benefits of mvnd while sticking to that "build image" concept (building in a docker container).
A couple of questions pop up:
So, with mvnd on the host all is awesome - assuming you build (call mvnd) on the host too (and not in some docker container).
I'm wondering if there's a way to have 1 single long-running mvnd container (running all the time), and then when i launch my own build docker container (mounting project x sources), it somehow connects to the long-running mvnd, such that my build container talks to that long-running mvnd to get the mvn job done faster.
The text was updated successfully, but these errors were encountered: