简体   繁体   English

fabric8 Maven 插件内联汇编问题

[英]fabric8 Maven Plugin Inline Assembly issue

I want to include some JAR files in my Docker image.我想在我的 Docker 图像中包含一些 JAR 文件。 I'm using the fabric8 maven plugin's inline assembly feature.我正在使用 fabric8 maven 插件的内联汇编功能。

Here is a the dependency in the POM:这是 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:这是 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>

The JAR is copied to the target/docker/... directory. JAR 被复制到target/docker/...目录。 Screenshot:截屏:

智能截图

I build the image, run the container, and into it.我构建图像,运行容器,然后进入它。 However, the JAR is missing.但是,缺少 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

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.插件发出警告: [WARNING] DOCKER> Dockerfile /load-testing/Dockerfile does not contain an ADD or COPY directive to include assembly created at maven. Ignoring assembly. [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?我必须使用 COPY 将文件从 Docker 映像中复制吗? I don't get that from free from the plugin?我不是从插件中免费获得的吗? Or did I just misconfigure something?还是我只是配置错误?

I also ran into this when trying an external Dockerfile.我在尝试外部 Dockerfile 时也遇到了这个问题。 The assembly only copies it to the target folder where you still need to use COPY in the Dockerfile to get it.该程序集仅将其复制到目标文件夹,您仍然需要在 Dockerfile 中使用 COPY 来获取它。 So you are right, you seem to need both.所以你是对的,你似乎需要两者。

If you only need the jars you can also use this in your pom如果你只需要 jars 你也可以在你的 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)但是您仍然需要像这样将它们复制到 Dockerfile 中(如果您未在程序集中提供名称,则 maven 是默认文件夹名称)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM