groupId :com.spotify
artifactId : docker-maven-plugin
version : 1.2.2
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<imageName>order-api</imageName>
<!--
指定 Dockerfile 所在的文件目录
-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/xxx.jar
COPY ${JAR_FILE} xxx.jar
ENTRYPOINT ["java","-jar","/xxx.jar"]
mvn clean package docker:build -Dmaven.test.skip=true -X