<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!--<version>3.1.6</version>-->
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.csdn</groupId>
<artifactId>blog</artifactId>
<name>blog</name>
<description>Demo project for Spring Boot</description>
<properties>
<dadao.version>1.0.0-RELEASE</dadao.version>
<java.version>1.8</java.version>
<docker.host>192.168.10.194:2375</docker.host>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>blog-${dadao.version}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<!--如果package时不想用docker打包,就注释掉这个goal-->
<!--<goal>build</goal>-->
<!--<goal>push</goal>-->
</goals>
</execution>
</executions>
<configuration>
<!-- 远程docker地址 -->
<dockerHost>${docker.host}</dockerHost>
<!--镜像名-->
<imageName>${project.artifactId}</imageName>
<!--TAG,这里用工程版本号-->
<imageTags>
<imageTag>${project.version}</imageTag>
</imageTags>
<!--指定Dockerfile路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!--suppress UnresolvedMavenProperty -->
<entryPoint>["java","-Xmx512m", "-Xms256m", "-jar","/${project.build.finalName}.jar","--spring.profiles.active=${profiles.active}"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
Name:自定义
Dockerfile:选择上一步创建的Dockerfile文件
ImageTag:镜像标签自定义
ContainerName:容器名称自定义
BindPort:前一个是服务器对外暴露端口(访问服务使用),后一个是容器端口。
maven package:进行打包
run:进行推送
。。。
。。。