springboot 通过docker 打包编译镜像

springboot 通过docker 打包编译镜像

 

添加plugin

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>peacock</artifactId>
        <groupId>cn.xiaojf</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>peacock-eureka</artifactId>

    <properties>
        <docker.registry.host>192.168.1.57:5000</docker.registry.host>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>${spring-boot-admin.version}</version>
        </dependency>
    </dependencies>

    <build>
        <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.0</version>
                <configuration>
            <!-- 镜像名称 --> <imageName>${docker.registry.host}/${project.artifactId}:${project.version}</imageName>
            <!-- 基础镜像 --> <baseImage>java:8-jre-alpine</baseImage> <!--Dockerfile的位置 --> <!--<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>-->
            <!-- 容器启动后执行命令 --> <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
            <!-- 复制jar包到镜像中 --> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin>
</plugins> </build> </project>

 

 执行build命令

发布镜像到私有registry

查看结果

meiya@meiya:~$ docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
192.168.1.57:5000/peacock-eureka   1.0-SNAPSHOT        339ecba6521d        12 minutes ago      163MB
jrebel-ls                          latest              4ef60f55bcc3        About an hour ago   115MB
192.168.1.57:5000/tomcat           latest              27600aa3d7f1        44 hours ago        463MB
tomcat                             latest              27600aa3d7f1        44 hours ago        463MB
registry                           latest              f32a97de94e1        2 months ago        25.8MB
java                               8-jre-alpine        fdc893b19a14        2 years ago         108MB

 

查看私服
meiya@meiya:~$ curl http://localhost:5000/v2/_catalog
{"repositories":["peacock-eureka","tomcat"]}

 

posted @ 2019-05-10 17:55 肖建锋 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值