docker-maven-plugin (fabric8) 的多次使用

Multiple usage of docker-maven-plugin (fabric8)

我想将 io.fabric8 中的 docker-maven-plugin 用于多种用途:

  1. 使用 docker 启动数据库服务器以进行集成测试(故障安全)。
  2. 构建我的产品的 Dockerfile

两者分开工作。

1:

<plugin>
  <groupId>io.fabric8</groupId>
  <artifactId>docker-maven-plugin</artifactId>
  <version>0.24.0</version>
  <executions>
    <execution>
     <id>start</id>
     <phase>pre-integration-test</phase>
     <goals>
       <goal>build</goal>
       <goal>start</goal>
     </goals>
   </execution>
   <execution>
     <id>stop</id>
     <phase>post-integration-test</phase>
     <goals>
       <goal>stop</goal>
     </goals>
   </execution>
 </executions>
 <configuration>
   <dockerHost>#HOST#</dockerHost>
     <images>
       <image>
         <name>sath89/oracle-xe-11g:latest</name>
         <run>
          <ports>
            <port>1521:1521</port>
          </ports>
          <wait>
            <log>Database ready to use. Enjoy!</log>
            <time>900000</time>
          </wait>
        </run>
      </image>
    </images>
  </configuration>
</plugin>

2:

<plugin>
  <groupId>io.fabric8</groupId>
  <artifactId>docker-maven-plugin</artifactId>
  <version>0.24.0</version>
  <configuration>
    <verbose>true</verbose>
    <dockerHost>#HOST#</dockerHost>
    <registry>#REGISTERY#</registry>
    <images>
      <image>
        <name>#NAME#</name>
        <build>
          <dockerFileDir>${project.basedir}</dockerFileDir>
        </build>
      </image>
    </images>
  </configuration>
  <executions>
    <execution>
      <id>build-image-and-push</id>
      <phase>install</phase>
      <goals>
        <goal>build</goal>
        <goal>push</goal>
      </goals>
    </execution>
  </executions>
</plugin>

当我合并这两个配置时,一切都搞砸了。有没有办法只将图像用于集成测试? 我如何定义我的项目的镜像不应该构建在数据库的镜像中?

将图像配置移动到 <execution> 有帮助!