<build>
<plugins>
<!--maven docker插件-->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.maven.plugin.version}</version>
<!--將插件綁定在某個phase執行-->
<executions>
<execution>
<id>buid-image</id>
<!--用戶只需執行mvn package,自動執行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<!--指定鏡像名-->
<imageName>xx/${project.artifactId}:${project.version}</imageName>
<!--指定標簽-->
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<!--指定基礎鏡像-->
<baseImage>java:8</baseImage>
<!--指定遠程docker地址-->
<!--TLS證書,使用https協議-->
<dockerHost>https://47.123.123.123:2376</dockerHost>
<!--配置TLS證書在系統中的路徑-->
<dockerCertPath>/Users/root/docker-ca</dockerCertPath>
<entryPoint>
["java", "-jar", "-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]
</entryPoint>
<!--復制jar包到docker容器指定目錄-->
<resources>
<resource>
<targetPath>/</targetPath>
<!--jar包在項目中生成的路徑,即對應的target目錄-->
<directory>${project.build.directory}</directory>
<!--指定需要復制的文件-->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>