docker-maven-plugin
docker-maven-plugin copied to clipboard
Assembly included in image seems to be incorrect
Description
When configuring a project with a .jar
artifact to include the artifact
(as the descriptorRef
) assembly in the final image includes a docker-build
file instead. I imagine this has to do with a misconfiguration or misunderstanding of how to configure the plugin, but, having checked resources such as issues and tutorials, I still can't fix this.
So I have a Spring Boot project which builds a jar artifact with the application, I'm trying to add the configured plugin so the artifact is an image with the generated jar inside. The pom.xml file looks like this:
...
<groupId>a.group</groupId>
<artifactId>theId</artifactId>
<version>0.1.0</version>
<packaging>docker-build</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath/>
</parent>
...
<build>
...
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.40.3</version>
<extensions>true</extensions>
<configuration>
<images>
<image>
<name>${project.artifactId}:${project.version}</name>
<build>
<from>openjdk:11-jre-slim</from>
<assembly>
<descriptorRef>artifact</descriptorRef>
<targetDir>/opt/${project.artifactId}</targetDir>
</assembly>
<entryPoint>java -jar /opt/${project.artifactId}/${project.artifactId}-${project.version}.jar</entryPoint>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
...
After the image is built with the following command:
$ mvn clean install
I run a container using the image and I get this artifact:
$ ls /opt/theId
theId-0.1.0.docker-build
I was expecting the extension to be .jar
, but I'm sure I'm missing something related to the packaging
defined.
Thanks!
Info
- docker-maven-plugin version : 0.40.3
- Maven version (
mvn -v
) :
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven hame: /opt/maven
Java version: 11.0.16, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-193-generic", arch: "amd64", family: "unix"
- Docker version :18.09.3, build 77pa1f4
- If it's a bug, how to reproduce : N/A
- If it's a feature request, what is your use case : N/A
- Sample project : N/A
Still waiting for an answer but, in case anyone bumped into this, as workaround, we're executing:
$ mvn package docker:build
With the default Maven project packaging (jar
) and no <extensions>
tag enabled.