Spring Boot 如何使用fabric 8-maven-plugin标记图像?

agyaoht7  于 7个月前  发布在  Spring
关注(0)|答案(2)|浏览(93)

我想用fabric 8-maven-plugin构建一个Docker镜像,并将其推送到自定义注册表(gcr.io/<myid>/demo123)。然而,maven插件总是使用项目的group/artifact id来派生镜像标签。我想我可以通过<image><name>标签手动配置标签,但这不起作用.有什么想法吗?
执行maven目标fabric8:build会导致

[INFO] F8: Successfully tagged example/demo:snapshot-180210-220255-0223
[INFO] F8: [example/demo:snapshot-180210-220255-0223] "spring-boot": Built image sha256:003d6
[INFO] F8: [example/demo:snapshot-180210-220255-0223] "spring-boot": Tag with latest

字符串
这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>3.5.33</version>
            <configuration>
                <verbose>true</verbose>
                <images>
                    <image>
                        <name>gcr.io/myid/demo123</name>
                    </image>
                </images>
            </configuration>
            <executions>
                <execution>
                    <id>fmp</id>
                    <goals>
                        <goal>resource</goal>
                        <goal>build</goal>
                        <goal>push</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


提前感谢!
解决方案:https://github.com/fabric8io/fabric8-maven-plugin/issues/1180

3zwtqj6y

3zwtqj6y1#

遇到了同样的问题。添加标记build解决了它。无法解释原因,也许其他人知道。

<images>
  <image>
    <name>gcr.io/myid/demo123</name>
    <build></build>
  </image>
</images>

字符串

pkln4tw6

pkln4tw62#

我在pom.xml中这样配置,它工作了

buildprofile



io.fabric8
fabric8-maven-plugin
3.5.35

        <configuration>
        <images>
    <image>
      <name>{image.user}/{image.name}:{image.tag}</name>
    </image>
  </images>
</configuration>

<executions>
  <execution>
    <goals>
      <goal>resource</goal>
      <goal>build</goal>
    </goals>
  </execution>
</executions>

相关问题