docker-maven-plugin
docker-maven-plugin copied to clipboard
Can't use <packaging>docker</packaging> in a multi-module project
Description
I'm trying to use the io.fabric8:docker-maven-plugin:0.44.0
plugin in a multi-module project. One of the modules has <packaging>docker</packaging>
. In this module i want to push the built image. Here is a fragment of pom.xml
:
...
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<images>
<image>
<name>k8s-tests/undertow</name>
<run>
<ports>
<port>8080:8080</port>
</ports>
</run>
</image>
</images>
<pushRegistry>${ACCOUNT_NUMBER}.dkr.ecr.${AWS_REGION}.amazonaws.com</pushRegistry>
</configuration>
</plugin>
...
Now, if I execute mvn clean deploy
, such that to perform the push
operation which is bound to the deploy
phase, I get the following maven exception:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for k8s-tests :: the master POM 1.0-SNAPSHOT:
[INFO]
[INFO] k8s-tests :: the master POM ........................ FAILURE [ 0.108 s]
[INFO] k8s-tests :: The EKS platform module ............... SKIPPED
[INFO] k8s-tests :: the web server module ................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.750 s
[INFO] Finished at: 2024-03-28T18:12:28+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy (default-deploy) on project k8s-tests: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::url parameter -> [Help 1]
This exception is raised in the master POM which tries to execute the default deploy
goal and it doesn't find the target repository. In order to avoid that, I'm adding the following to the master POM:
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
...
But then running mvn clean deploy
the push
operation is skipped.
How could I skip the deploy goal everywhere but in a single module ?
Info
-
docker-maven-plugin version : 0.44.0
-
Maven version (
mvn -v
) :Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546) Maven home: /opt/apache-maven-3.9.5 Java version: 17.0.6, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-17 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-101-generic", arch: "amd64", family: "unix"
-
Docker version :
Docker version 25.0.5, build 5dc9bcc
-
If it's a bug, how to reproduce :
Don't have a reproducer
Finally, I adopted another solution: I simply defined
...
<properties>
...
<maven.deploy.skip>true</maven.deploy.skip>
...
</properties>
...
in the master POM and:
...
<properties>
...
<maven.deploy.skip>false</maven.deploy.skip>
...
</properties>
...
in the module where I want to do the push
. But it doesn't work neither, I get the following:
INFO] --- docker:0.44.0:start (default-start) @ k8s-web ---
[INFO] DOCKER> [k8s-tests/undertow:latest]: Start container a5814d59d295
[INFO]
[INFO] --- failsafe:3.0.0-M4:integration-test (default-integration-test) @ k8s-web ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running fr.simplex_software.k8s.tests.it.UndertowServerIT
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.913 s - in fr.simplex_software.k8s.tests.it.UndertowServerIT
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- docker:0.44.0:copy (default-copy) @ k8s-web ---
[INFO]
[INFO] --- docker:0.44.0:stop (default-stop) @ k8s-web ---
[INFO] DOCKER> [k8s-tests/undertow:latest]: Stop and removed container a5814d59d295 after 0 ms
[INFO]
[INFO] --- failsafe:3.0.0-M4:verify (default-verify) @ k8s-web ---
[INFO]
[INFO] --- docker:0.44.0:push (default-push) @ k8s-web ---
[INFO] DOCKER> [k8s-tests/undertow:latest] : Skipped pushing
So, the plugin performs the start
, integration-test
and stop
goals bound to the install
phase but skips the push
one, bound to the deploy
phase.
This seems to be specifically related to this plugin and to the docker
packaging.