fabric8 Maven Plugin Inline Assembly issue

1.3k Views Asked by At

I want to include some JAR files in my Docker image. I'm using the fabric8 maven plugin's inline assembly feature.

Here is a the dependency in the POM:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>${activemq.version}</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>${org.json.version}</version>
    <type>jar</type>
</dependency>

And here is the inline assembly for the fabribc8 plugin:

<assembly>
    <inline>
        <id>copy-jars</id>
        <dependencySets>
            <dependencySet>
                <includes>
                    <include>*</include>
                </includes>
                <outputDirectory>/opt/apache-jmeter-5.1.1/lib</outputDirectory>
            </dependencySet>
        </dependencySets>
    </inline>
</assembly>

The JAR is copied to the target/docker/... directory. Screenshot:

intellij-screenshot

I build the image, run the container, and into it. However, the JAR is missing.

bash-4.4# ls -l /opt/apache-jmeter-5.1.1/lib/*active*
ls: /opt/apache-jmeter-5.1.1/lib/*active*: No such file or directory

There is a warning from the plugin: [WARNING] DOCKER> Dockerfile /load-testing/Dockerfile does not contain an ADD or COPY directive to include assembly created at maven. Ignoring assembly.

I have to use a COPY to copy the files from into the Docker image? I don't get that from free from the plugin? Or did I just misconfigure something?

1

There are 1 best solutions below

0
On BEST ANSWER

I also ran into this when trying an external Dockerfile. The assembly only copies it to the target folder where you still need to use COPY in the Dockerfile to get it. So you are right, you seem to need both.

If you only need the jars you can also use this in your pom

<assemblies>
 <assembly>
  <descriptorRef>artifact-with-dependencies</descriptorRef>
 </assembly>
</assemblies>

but you still need to copy them in the Dockerfile like this (maven is the default folder name if you don't provide a name in the assembly)

COPY maven/ /opt/apache-jmeter-5.1.1/lib/