Springboot相关--Docker构建springboot项目

160 阅读1分钟

一、Springboot项目上传至阿里云镜像仓库

  • 在pom中添加如下配置
<build>
        <plugins>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <from>
                        <!--base image -->
                        <image>anapsix/alpine-java:8_server-jre_unlimited</image>
                    </from>
                    <to>
                        <!--目标镜像registry地址,:前面是发布镜像的名称,:后面是发布的版本号 -->
                        <image>  </image>

                        <!-- 阿里云镜像账号 -->
                        <auth>
                            <username>user</username>
                            <password>pwd</password>
                        </auth>
<!--                        <tags>-->
<!--                            <tag>tag</tag>-->
<!--                            <tag>latest</tag>-->
<!--                        </tags>-->
                    </to>
                    <allowInsecureRegistries>true</allowInsecureRegistries>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  • 使用idea插件进行打包

image.png

二、docker构建Springboot项目