Open mszalbach opened 1 year ago
Do you think this could be related to https://github.com/fabric8io/docker-maven-plugin/issues/1146 ?
Yes from the commit I guess this issue should be the one changing the behavior because now the docker:build command requires a dependency solution, which was not the case before. With Maven 4-alpha3 the same example would work, because Maven would be smarter in resolving own child dependencies.
Did some more testing and with the change to dependency resolve I am not able to get docker:build working as standalone command in a multimodule project, because there will always a child which can not be resolved.
So it would always needs a ./mvnw package docker:build
and it not possible to separate this steps in multi stages on the CI server anymore like it was possible with 0.40.2
Simple workaround is to call docker:build with a project list so maven did not resolve everything. So having the pom.xml in the parrent and calling ./mvn -pl . docker:build
solves the issue and you can still use the simple top level Dockerfile with versions >0.40.2
@mszalbach unfortunately using ./mvn -pl . docker:build does not work when calling from module pom.xml
We also ran into this problem right now. We build the docker image in a submodule via Dockerfile, that is also located in the submodule. When using 0.40.2, all is fine, with the current 0.43.4 it does not work.
@Dalamaar : Could you please share a reproducer project?
Sure, here it is: https://github.com/Dalamaar/maven-docker-plugin (It is an adjusted fork of the example of @mszalbach)
The Dockerfile is located in the app-submodule, as well as the dependency to the docker-maven-plugin. When calling "mvn package" and then "mvn docker:build" it works with 0.40.2, but not 0.43.4. "mvn package docker:build" is working.
Calling "mvn -pl app docker:build -am" is also not working in the new version. In the old one it is, as far as I can tell.
@Dalamaar : Thanks for sharing. Are you testing this on linux environment or mac?
We work on Windows with Docker Desktop.
Description
With versions before 0.40.3 it was possible to have a multi module project and use the Simple Dockerfile build configuration (Dockerfile at parent level) and separate the package step and the docker:build step. With the version 0.40.3 the plugin changes something in the Maven build process and Maven wants to download one of the child dependencies from a repository, which was not necessary with version 0.40.2.
Probably easier to see in the example project > https://github.com/mszalbach/maven-docker-plugin-403
Checkout and call
./mvnw package
and afterwards try a./mvnw docker:build
the build will fail withWhen changing the version of the docker maven plugin to 0.40.2 it works.
Info
docker-maven-plugin version : 0.40.3
Maven version (
mvn -v
) : 3.8.6Docker version : Docker version 20.10.22
If it's a bug, how to reproduce :
Sample project : maven-docker-plugin-403