-
Notifications
You must be signed in to change notification settings - Fork 645
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
incremental building: docker:build-watch for detecting new SNAPSHOT jars in flat classloaders that go into /maven #187
Comments
If I understand you right, you want to create a new image with a What should happen with the repo name of the old image ? It should probably moved to the new image (to the top layer). |
@rhuss yeah thats right. The watching part could use volumes like this https://github.com/rhuss/docker-maven-plugin/issues/119 - or could create Yes, we should move the new incremental image to the new image name (e.g. 1.0-SNAPSHOT) (maybe label the old one as 1.0-SNAPSHOT.old.X' or something? |
Another idea for cleaining up image: Always create imags with a tag suffix like One could even go so far to cleanup automatically with a ShutdownHook when using |
we can add multiple labels to an image can't we; so we could use some 'incremental tag' prefix/suffix when we create the image; then when we label it with the project version (1.0-SNAPSHOT say) we can have 2 labels? So that the latest image (via |
I see your point with references in deployment descriptors which would then be different. My point is, that although you can have multiple labels you can have only one unique tag. If we promote (and maybe even verify) that 'development'/'incremental' image may have only But maybe we should start small and simply recreate the whole image, maybe with (flag-enabled0 removing the old image after building it so that we keep a clean repo. Might be not so fast, but its much easier than to create a custom image layer on top (frankly, I dont know yet how to do this, keeping all the metadata like commands etc. on the top layer) |
Yeah. Maybe in incremental/continuous build mode we should just use latest as the docker image label anyway? Then it's clear from the image name in the kubernetes JSON that we're using the latest snapshot? Might be nice in general in the docker plugin to default the image tag to latest if the project version ends in SNAPSHOT too? In fabric8 we tend to use ${project.version} in the docker.image property - maybe the docker plugin should generate its own property folks can use - say - ${docker.image.tag} which if not defined it's set to latest for snapshots or use ${project.version}? |
You can omit the tag when specifying the image name, that implicitly creates a Also, you can always add more tags with the |
Good news, I found a rather easy way to find the list of source files in an assembly (using a Next step is to detangle the When it comes to rebuilding images during watching, my plan is to support the following features:
Options which could influence this behaviour:
There are still some interesting open questions:
My roadmap for this is:
Hmm, quite some stuff. But I think its worth to go in this direction since it would make dev's life a lot easier. What's your opinion on this ? |
These are the use case scenarios I have in mind:
Any other use cases ? |
A new "watch" goal has been introduced which is useful during development for automatic building and restarting Docker images. #187
for the documentation of `docker:watch` (#187)
The postgoal needs to be specified as `<pluginGroupId>:<pluginArtifactId>:<goal>` either globally in `<watchPostGoal>` or specifically for each image in the `<watch>` section as `<postGoal>` #187
Mostly implemented, the rest has been distributed to new issues. Closing that one. |
when working with Apache Karaf there's a really handy command
dev:watch *
. You provision your bundles to karaf then if you rebuild any jar/bundle thats a SNAPSHOT via "mvn install", this command will watch your local maven repo for any SNAPSHOT jars that are deployed that get rebuilt. If they do it redeploys those bundles into the Karaf container. (For more detail see the watch section at the bottom of this page.As a developer you just run
dev:watch *
then anymvn install
in any other maven project for a SNAPSHOT jar will redeploy your stuff! Its a very neat way to reduce the compile/build/deploy time.It'd be cool to have something similar for folks developing flat class loader docker images (e.g. camel boot / spring boot / dropwizard / wildfly swarm).
Imagine if we could do something like:
This would then look at all the jars in the /maven folder for the docker image (using the local target/docker/...maven folder that the
mvn docker:build
created locally), find all the SNAPSHOT jars/wars and watch them in the~/.m2/repository
local repository until a user hits a key to break the watch loop.For any jar/war thats changed, we know that this jar needs to go into /maven in the docker image; so we create a new image, based on the last image created, copying this new jar into the place we know it goes.
i.e. we'd get development time fast docker builds; only the changed jars need to be POSTed (or ADD'ed to the Dockerfile) so it should be really fast.
i.e. we assume a full valid build is done first via
mvn docker:build
; thenmvn docker:build-watch
is an incremental build from then on watching to see if any artifact included in the docker image changes; we're then doing the absolute minimum to create a new image based on the last one, only copying changed jars into the new image.This is only for incremental development mind you; we'd use the real
mvn docker:build
for releases. It'd just really cut down the amount of time developers spend typing mvn commands and buildingThe text was updated successfully, but these errors were encountered: