1)在工程的pom.xml文件中添加Docker插件

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <configuration>
        <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
        <baseImage>java:8</baseImage>
        <entryPoint>["java", "-jar", "/${project.build.finalName}.war"]</entryPoint>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.war</include>
            </resource>
        </resources>
    </configuration>
</plugin>

工程本身包含了前端代码,打的是war包(打成jar包会导致页面不可访问)

<packaging>war</packaging>

2)在pom.xml目录下执行

mvn package docker:build

 

 

转载于:https://my.oschina.net/u/4042451/blog/3038305

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐