fabric8 Maven 插件内联组装问题

fabric8 Maven Plugin Inline Assembly issue

我想在我的 Docker 图像中包含一些 JAR 文件。我正在使用 fabric8 maven 插件的内联汇编功能。

这是 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>

这里是 fabribc8 插件的内联程序集:

<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>

JAR 被复制到 target/docker/... 目录。截图:

我构建图像,运行 容器,然后放入其中。但是,缺少 JAR。

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

插件发出警告: [WARNING] DOCKER> Dockerfile /load-testing/Dockerfile does not contain an ADD or COPY directive to include assembly created at maven. Ignoring assembly.

我必须使用 COPY 将文件从中复制到 Docker 图像中吗?我不是从插件中免费得到的吗?还是我配置有误?

我在尝试外部 Dockerfile 时也 运行 参与其中。该程序集仅将其复制到目标文件夹,您仍然需要在 Dockerfile 中使用 COPY 来获取它。所以你是对的,你似乎两者都需要。

如果你只需要罐子,你也可以在你的 pom 中使用它

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

但您仍然需要像这样将它们复制到 Dockerfile 中(如果您不在程序集中提供名称,则 maven 是默认文件夹名称)

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