讀取Dockerfile進(jìn)行構(gòu)建
10年積累的成都網(wǎng)站建設(shè)、網(wǎng)站制作經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站策劃后付款的網(wǎng)站建設(shè)流程,更有雨城免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
在項目的/src/main目錄下創(chuàng)建docker目錄
將Dockerfile文件添加進(jìn)去
Dockerfile內(nèi)容如下
FROM java:8
MAINTAINER dengyunshuo <dengyunshuo@163.com>
COPY *.jar /
ENTRYPOINT ["java","-jar", "/power-dubbo-provider-1.0-SNAPSHOT.jar"]
插件配置如下
<!-- docker的maven插件,官網(wǎng):https://github.com/spotify/docker-maven-plugin -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>com.spotify</groupId>
? ? ? ? ? ? ? ? <artifactId>docker-maven-plugin</artifactId>
? ? ? ? ? ? ? ? <version>0.4.12</version>
? ? ? ? ? ? ? ? <executions>
? ? ? ? ? ? ? ? ? ? <execution>
? ? ? ? ? ? ? ? ? ? ? ? <id>build-image</id>
? ? ? ? ? ? ? ? ? ? ? ? <phase>package</phase>
? ? ? ? ? ? ? ? ? ? ? ? <goals>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <goal>build</goal>
? ? ? ? ? ? ? ? ? ? ? ? </goals>
? ? ? ? ? ? ? ? ? ? </execution>
? ? ? ? ? ? ? ? </executions>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <!-- 注意imageName一定要是符合正則[a-z0-9-_.]的,否則構(gòu)建不會成功 -->
? ? ? ? ? ? ? ? ? ? <!-- 詳見:https://github.com/spotify/docker-maven-plugin? ? Invalid repository name ... only [a-z0-9-_.] are allowed-->
? ? ? ? ? ? ? ? ? ? <imageName>${project.artifactId}:${project.version}</imageName>
? ? ? ? ? ? ? ? ? ? <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
? ? ? ? ? ? ? ? ? ? <resources>
? ? ? ? ? ? ? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <targetPath>/</targetPath>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <directory>${project.build.directory}</directory>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <include>${project.build.finalName}.jar</include>
? ? ? ? ? ? ? ? ? ? ? ? </resource>
? ? ? ? ? ? ? ? ? ? </resources>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
------------------------------------------------------------------------------------------------------
插件配置
<plugin>
? ? ? ? ? ? ? ? <groupId>com.spotify</groupId>
? ? ? ? ? ? ? ? <artifactId>docker-maven-plugin</artifactId>
? ? ? ? ? ? ? ? <version>0.4.12</version>
? ? ? ? ? ? ? ? <executions>
? ? ? ? ? ? ? ? ? ? <execution>
? ? ? ? ? ? ? ? ? ? ? ? <id>build-image</id>
? ? ? ? ? ? ? ? ? ? ? ? <phase>package</phase>
? ? ? ? ? ? ? ? ? ? ? ? <goals>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <goal>build</goal>
? ? ? ? ? ? ? ? ? ? ? ? </goals>
? ? ? ? ? ? ? ? ? ? </execution>
? ? ? ? ? ? ? ? </executions>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <!-- 注意imageName一定要是符合正則[a-z0-9-_.]的,否則構(gòu)建不會成功 -->
? ? ? ? ? ? ? ? ? ? <!-- 詳見:https://github.com/spotify/docker-maven-plugin? ? Invalid repository name ... only [a-z0-9-_.] are allowed-->
? ? ? ? ? ? ? ? ? ? <imageName>power-dubbo-provider</imageName>
? ? ? ? ? ? ? ? ? ? <baseImage>java</baseImage>
? ? ? ? ? ? ? ? ? ? <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
? ? ? ? ? ? ? ? ? ? <resources>
? ? ? ? ? ? ? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <targetPath>/</targetPath>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <directory>${project.build.directory}</directory>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <include>${project.build.finalName}.jar</include>
? ? ? ? ? ? ? ? ? ? ? ? </resource>
? ? ? ? ? ? ? ? ? ? </resources>
? ? ? ? ? ? ? ? </configuration>
</plugin>
通過執(zhí)行package打包既可
文章名稱:maven插件構(gòu)建Docker鏡像
網(wǎng)頁URL:http://muchs.cn/article18/geeodp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站策劃、移動網(wǎng)站建設(shè)、微信小程序、網(wǎng)站建設(shè)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)