<?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>spring-cloud-docker</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-eureka</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!– 镜像前缀,推送镜像到远程库时需要,这里配置了一个阿里云的私有库 –>
<docker.image.prefix>
registry.cn-huhehaote.aliyuncs.com/monkeybrain
</docker.image.prefix>
<!– docker镜像的tag –>
<docker.tag>latest</docker.tag>
<!– 激活的profile –>
<!–<activatedProperties></activatedProperties>–>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
</dependencies>
<profiles>
<!– docker环境 –>
<!–<profile>
<id>docker</id>
<properties>
<activatedProperties>docker</activatedProperties>
<docker.tag>docker-demo-${project.version}</docker.tag>
</properties>
</profile>–>
</profiles>
<build>
<!–默认maven命令–>
<defaultGoal>install</defaultGoal>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!– 配置spring boot maven插件,把项目打包成可运行的jar包 –>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<!– 打包时跳过单元测试 –>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!– 配置docker maven插件,绑定install生命周期,在运行maven install时生成docker镜像 –>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<!–<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
<goal>tag</goal>
</goals>
</execution>
</executions>–>
<configuration>
<!– 修改这里的docker节点ip,需要打开 docker节点的远程管理端口2375,
具体如何配置可以参照之前的 docker安装和配置的文章 –>
<dockerHost>http://localhost:2375</dockerHost>
<imageName>${docker.image.prefix}/${project.build.finalName}</imageName>
<serverId>aliyun-docker-registry</serverId>
<registryUrl>registry.cn-huhehaote.aliyuncs.com</registryUrl>
<pushImage>true</pushImage>
<!–镜像的标签–>
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<!–基础镜像–>
<baseImage>java:8</baseImage>
<!– 这里的 entryPoint 定义了容器启动时的运行命令,容器启动时运行 java -jar 包名 –>
<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>
<!–<image>${docker.image.prefix}/${project.build.finalName}</image>
<newName>${docker.image.prefix}/${project.build.finalName}:${docker.tag}</newName>
<forceTags>true</forceTags>–>
<!– 如果需要在生成镜像时推送到远程库,pushImage设为true –>
<!–<pushImage>false</pushImage>–>
</configuration>
</plugin>
</plugins>
</build>
</project>