跟随书中,使用 Spotify 公司开发的 Maven 插件。
GitHub 地址:https://github.com/spotify/docker-maven-plugin#the-future-of-docker-maven-plugin
快速入门
- 在 pom 文件中添加:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<!-- 指定镜像名称 -->
<imageName>yhcm/microservice-discovery-eureka:${version}</imageName>
<!-- 指定基础镜像,类似Dockerfile 的 FROM -->
<baseImage>java</baseImage>
<!-- 类似于Dockerfile ENTRYPOINT 指令 -->
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<!-- copy the service's jar file from target into the root directory of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<!-- 指定需要复制的根目录。${project.build.dir