docker-maven-plugin
docker-maven-plugin copied to clipboard
When deployAtEnd is set, d-m-p should push docker images after a multi-module build
Description
The idea is cloned from maven-deploy-plugin. When the user property deployAtEnd is set, d-m-p should push all Docker images at the end of multi module build. These docker images are created during this multi module build.
- If it's a feature request, what is your use case : In a CI build I want to ensure that the multi module build runs successfully before the docker images are pushed to the registry.
Workaround:
mvn deploy -DdeployAtEnd -Ddocker.skip.push
mvn docker:push
I think it's relate to #745
I see the use case, but how would a parent pom know which images to push ? 'would have to check how the deploy plugin deals with this and maybe one can also already achieve that with d-m-p with some clever lifecycle bindings, so that the sub-modules push e.g. on the postInstall
phase (which is reached only when the build doesn't break before.
I discussed the solution of the deploy plugin with @khmarbaise. He recommends me to use the Maven deployer extension for this use case in deploy plugin. Maybe for this issue it would be a good idea to write a docker push extension. What do you think?
I'm not very familiar with extensions, but sounds like a good idea ;-) Such an extension then could pick up all images to push at the end of the whole run.
I would happy to help to integrate any PR which goes in this direction.
Yes, please please make it work, it is very much needed :). We often have this kind of structure
Parent-Aggregator |-- Module A (e.g. a common Business API) |-- Module B, depends on A, defines image X |-- Module C, depends on A, defines image Y |-- Module D, product assembly, defines E2E tests and runs them utilizing images. Defines E2E test image
We usually only ever want to push images, after all E2E Tests were done.
I release the first version of the Maven Extension. It is available in Maven Central
This is a great idea, but I see that both this plugin and its inspiration plugin are in the POC Phase. Any plans to make either of these extensions production-ready, or push the change upstream to the modified plugins?
@tpischke-bedag Could you test the current release version of the Maven extension and give me feedback if it works in your use case? IMHO there are some dependencies clean-ups to do. If it is better for the community, I can move the Maven extension to this project (@rhuss what do you think?). But we cannot merge it with the plugin because a Maven extension is a separate concept towards a Maven plugin.
Thus looks promising, but of course, there's always something new to deal with – in particular, some users are likely to move away from fabric8 and to https://www.eclipse.org/jkube/ , which is apparently its designated successor. But that can be dealt with later.
@TIBCOrkrajews : JKube is the successor to Fabric8 Maven Plugin not Docker Maven Plugin. It's applicable for users who are working with Kubernetes. This project is still alive and maintained.
@tpischke-bedag Could you test the current release version of the Maven extension and give me feedback if it works in your use case? IMHO there are some dependencies clean-ups to do. If it is better for the community, I can move the Maven extension to this project (@rhuss what do you think?). But we cannot merge it with the plugin because a Maven extension is a separate concept towards a Maven plugin.
We solved this by adding a dedicated deployment maven Module for the moment, but we will try testing this and providing feedback hopefully soon.
@tpischke-bedag Could you test the current release version of the Maven extension and give me feedback if it works in your use case? IMHO there are some dependencies clean-ups to do. If it is better for the community, I can move the Maven extension to this project (@rhuss what do you think?). But we cannot merge it with the plugin because a Maven extension is a separate concept towards a Maven plugin.
During testing, I get the following error at the end of the build:
build 01-Jul-2021 13:25:08 [WARNING] Failed to notify spy com.github.sparsick.maven.docker.extension.DockerPushExtension: {"message":"invalid reference format"}
The push works normally when the extension is not active. The image name is composed using some maven properties, maybe they are not being resolved correctly?
<name>registry.example.com/${docker.namespace}/backend:git-commit-id_${git.commit.id}</name>
My suspicion is that the following code does not allow for interpolation of maven properties in the image name:
private void parseDockerImageName(Object configuration) {
LOGGER.debug("Configuration: {}", configuration);
// this is necessary because cast throw an exception "incompatible type"
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(configuration.toString()));
dockerImageNames.addAll(Arrays.stream(dom.getChild("images").getChildren("image")).map(image -> image.getChild("name").getValue()).collect(Collectors.toSet()));
LOGGER.info("Found docker image names: {}", dockerImageNames);
}
I haven't been able to get the extension to log any debug information, even with the maven -X flag, is there some trick to turn on the logging?
Added an issue in the project: https://github.com/sparsick/maven-docker-extension/issues/40