• 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","--spring.profiles.active=prod"]</entryPoint>
    <!-- 复制jar包到镜像中 -->
    <resources>
    <resource>
    <targetPath>/</targetPath>
    <directory>${project.build.directory}</directory>
    <include>${project.build.finalName}.jar</include>
    </resource>
    </resources>
    <imageTags>
    <imageTag>${project.version}</imageTag>
    <imageTag>latest</imageTag>
    </imageTags>
    </configuration>
    <executions>
    <execution>
    <id>build-image</id>
    <phase>install</phase>
    <goals>
    <goal>build</goal>
    </goals>
    </execution>

    <execution>
    <id>push-image</id>
    <phase>install</phase>
    <goals>
    <goal>push</goal>
    </goals>
    </execution>
    </executions>
    </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"]}
  • 相关阅读:
    Eclipse快捷键大全(转载)
    IE9浏览Flash页面时显示错位并不停地闪烁
    flash全屏事件和键盘按下事件部分不能触发问题
    AS3摘要(转载)
    【as3手册小记】ActionScript 中处理全屏模式的注意事项
    巧用FlashPaper 让Word文档变Flash
    AS3视频照相截图(转载)
    Json串到json对象的转换
    映射文件详解(转)
    Jquery .ajax方法分析(一)
  • 原文地址:https://www.cnblogs.com/xiaojf/p/10845835.html
Copyright © 2020-2023  润新知