Skip to main content

One post tagged with "harbor"

View All Tags

IntelliJ IDEA 推送镜像到harbor私库

· One min read
chenweibo

新增插件

        <dependency>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.40.2</version>
</dependency>

配置

需要一台docker跳板机

  <build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.40.2</version>
<configuration>
<!--认证配置,用于私有registry认证-->

<authConfig>
<username>xxx</username>
<password>xxx</password>
</authConfig>
<!-- harbor镜像仓库地址-->
<pushRegistry>https://harbor.xxx.com</pushRegistry>
<dockerHost>tcp://x.x.x.x:2375</dockerHost>
<images>
<image>
<!--推送到私有镜像仓库,镜像名需要添加仓库地址-->
<name>harbor.xxx.com/xxxxx/${project.name}:${project.version}</name>
<!--定义镜像构建行为-->
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-exec</id>
<!-- 绑定mvn install阶段,当执行mvn install时 就会执行docker build 和docker push-->
<phase>install</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

执行

mvn clean install