【问题标题】:liberty:devc: <dockerfile> not being honoredliberty:devc: <dockerfile> 不被尊重
【发布时间】:2021-06-10 22:34:26
【问题描述】:

我观察到&lt;dockerfile&gt; 元素,尽管它指向一个有效的Dockerfile,但liberty:devc 不支持它。

考虑mvn help:effective-pom的这个输出:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>javaee-cafe</groupId>
    <artifactId>javaee-cafe-parent</artifactId>
    <version>1.0.0</version>
    <relativePath />
  </parent>
  <groupId>javaee-cafe</groupId>
  <artifactId>javaee-cafe-jcache</artifactId>
  <version>1.0.3</version>
  <packaging>war</packaging>
  <name>javaee-cafe-jcache</name>
  <properties>
    <dockerFileName>Dockerfile</dockerFileName>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <!-- elided -->
    <usrDirectory>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr</usrDirectory>
  </properties>
  <dependencies><!-- elided --></dependencies>
  <build>
    <sourceDirectory>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/src/main/java</sourceDirectory>
    <!-- elided -->
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/src/main/resources</directory>
      </resource>
    </resources>
    <directory>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target</directory>
    <finalName>javaee-cafe-jcache</finalName>
    <plugins>
      <!-- elided -->
      <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId>
        <version>3.3.4</version>
        <executions>
          <execution>
            <id>package-server</id>
            <phase>package</phase>
            <goals>
              <goal>create</goal>
              <goal>install-feature</goal>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <container>true</container>
              <dockerfile>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/Dockerfile</dockerfile>
              <libertyRuntimeVersion>[21.0.0.5,)</libertyRuntimeVersion>
              <serverXmlFile>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer/server.xml</serverXmlFile>
              <copyDependencies><!-- elided --></copyDependencies>
              <outputDirectory>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/wlp-package</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
  </build>
</project>

当我运行mvn liberty:devc 时,我看到了这个输出:

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< javaee-cafe:javaee-cafe-jcache >-------------------
[INFO] Building javaee-cafe-jcache 1.0.3
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- liberty-maven-plugin:3.3.4:devc (default-cli) @ javaee-cafe-jcache ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-kernel:null:21.0.0.5:zip.
[INFO] CWWKM2102I: Using installDirectory : /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer.
<!-- elided -->
[INFO] Running liberty:deploy
[INFO] The liberty.runtime.version property value [21.0.0.5,) is used for the runtimeArtifact version.
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-kernel:null:21.0.0.5:zip.
[INFO] CWWKM2102I: Using installDirectory : /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer.
[INFO] Copying 1 file to /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer
[WARNING] The /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/src/main/liberty/config/server.xml file is overwritten by the /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer/server.xml file.
[INFO] Copying 1 file to /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
<!-- elided -->
[INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "apps".
[INFO] CWWKM2160I: Installing application javaee-cafe-jcache.war.xml.
[INFO] Parsing the server file /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer/server.xml for features and includes.
[INFO] Copying 1 file to /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.665 s
[INFO] Finished at: 2021-06-10T18:05:42-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.3.4:devc (default-cli) on project javaee-cafe-jcache: No Dockerfile was found at /home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/Dockerfile. Create a Dockerfile at the specified location to use dev mode with container support. For an example of how to configure a Dockerfile, see https://github.com/OpenLiberty/ci.docker -> [Help 1]
<!-- elided -->
Compilation exited abnormally with code 1 at Thu Jun 10 18:05:42

看起来&lt;dockerfile&gt;,虽然存在,但没有得到尊重。

<dockerfile>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/Dockerfile</dockerfile>

这是一个错误吗?

谢谢,

埃德

【问题讨论】:

    标签: websphere-liberty open-liberty liberty-maven-plugin


    【解决方案1】:

    解决方案:使用插件级配置(不是执行级)

    您需要在插件级别而不是执行级别添加配置。

    所以它应该看起来更像:

          <plugin>
            <groupId>io.openliberty.tools</groupId>
            <artifactId>liberty-maven-plugin</artifactId>
            <version>3.3.4</version>
            <configuration>
              <dockerfile>/home/edburns/workareas/open-liberty-on-aks/javaee-app-redisson/target/Dockerfile</dockerfile>
              <!-- ... rest of config ... -->
            </configuration>
          </plugin>
    

    liberty:devliberty:devc 目标将生命周期封装在单个目标中,在循环中迭代执行,但执行级配置没有太多用处。 (不确定这是否真的记录得很好。)

    其他想法

    如果您查看我们的示例指南中的pom.xml,例如this one,您会发现我们甚至无需费心配置绑定到包等阶段的其他 Liberty 目标,例如创建、部署等。

    我们只是使用 liberty:dev 和 liberty:devc 进行迭代开发,然后在构建镜像的时候,我们执行mvn package 让 maven-war-plugin 构建战争,然后执行 Docker 构建以将 WAR 构建到应用映像中。

    当然,您可能有理由将其包含在内,而我正在偏离主题,但只是在此处添加更多上下文。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-18
    • 2013-09-01
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 2019-09-18
    相关资源
    最近更新 更多