|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 4 | + <modelVersion>4.0.0</modelVersion> |
| 5 | + <parent> |
| 6 | + <groupId>org.springframework.boot</groupId> |
| 7 | + <artifactId>spring-boot-starter-parent</artifactId> |
| 8 | + <version>2.3.0.BUILD-SNAPSHOT</version> |
| 9 | + <relativePath/> <!-- lookup parent from repository --> |
| 10 | + </parent> |
| 11 | + <groupId>net.ameizi</groupId> |
| 12 | + <artifactId>k8s-example</artifactId> |
| 13 | + <version>1.0.0</version> |
| 14 | + <name>k8s-example</name> |
| 15 | + <description>Demo project for Spring Boot</description> |
| 16 | + |
| 17 | + <properties> |
| 18 | + <java.version>1.8</java.version> |
| 19 | + </properties> |
| 20 | + |
| 21 | + <dependencies> |
| 22 | + <dependency> |
| 23 | + <groupId>org.springframework.boot</groupId> |
| 24 | + <artifactId>spring-boot-starter-actuator</artifactId> |
| 25 | + </dependency> |
| 26 | + <dependency> |
| 27 | + <groupId>org.springframework.boot</groupId> |
| 28 | + <artifactId>spring-boot-starter-web</artifactId> |
| 29 | + </dependency> |
| 30 | + |
| 31 | + <dependency> |
| 32 | + <groupId>org.springframework.boot</groupId> |
| 33 | + <artifactId>spring-boot-devtools</artifactId> |
| 34 | + <scope>runtime</scope> |
| 35 | + <optional>true</optional> |
| 36 | + </dependency> |
| 37 | + <dependency> |
| 38 | + <groupId>org.springframework.boot</groupId> |
| 39 | + <artifactId>spring-boot-starter-test</artifactId> |
| 40 | + <scope>test</scope> |
| 41 | + <exclusions> |
| 42 | + <exclusion> |
| 43 | + <groupId>org.junit.vintage</groupId> |
| 44 | + <artifactId>junit-vintage-engine</artifactId> |
| 45 | + </exclusion> |
| 46 | + </exclusions> |
| 47 | + </dependency> |
| 48 | + </dependencies> |
| 49 | + |
| 50 | + <build> |
| 51 | + <plugins> |
| 52 | + <plugin> |
| 53 | + <groupId>org.springframework.boot</groupId> |
| 54 | + <artifactId>spring-boot-maven-plugin</artifactId> |
| 55 | + <configuration> |
| 56 | + <image> |
| 57 | + <name>k8s-example:latest</name> |
| 58 | + </image> |
| 59 | + </configuration> |
| 60 | + </plugin> |
| 61 | + <plugin> |
| 62 | + <groupId>com.google.cloud.tools</groupId> |
| 63 | + <artifactId>jib-maven-plugin</artifactId> |
| 64 | + <version>2.2.0</version> |
| 65 | + <executions> |
| 66 | + <execution> |
| 67 | + <phase>package</phase> |
| 68 | + <goals> |
| 69 | + <goal>build</goal> |
| 70 | + </goals> |
| 71 | + </execution> |
| 72 | + </executions> |
| 73 | + <configuration> |
| 74 | + <from> |
| 75 | + <image>openjdk:8-jdk-alpine</image> |
| 76 | + </from> |
| 77 | + <to> |
| 78 | + <!-- 坑!!!这里切记一定要设置 docker registry的完整地址,否则会被坑死,构建的时候会报授权错误,原因在于执行 mvn package 命令后会打包构建镜像并进行推送,因此要设置镜像仓库的地址,并且记得在命令行进行镜像仓库登录(docker login) --> |
| 79 | + <!-- 此处构建不依赖docker daemon进程。说人话就是不需要启动docker服务 --> |
| 80 | + <image>registry.hub.docker.com/aimeizi/k8s-example:latest</image> |
| 81 | + </to> |
| 82 | + <container> |
| 83 | + <mainClass>net.ameizi.k8s.example.K8sExampleApplication</mainClass> |
| 84 | + <ports> |
| 85 | + <port>8080</port> |
| 86 | + </ports> |
| 87 | + </container> |
| 88 | + </configuration> |
| 89 | + </plugin> |
| 90 | + </plugins> |
| 91 | + </build> |
| 92 | + |
| 93 | + <repositories> |
| 94 | + <repository> |
| 95 | + <id>spring-milestones</id> |
| 96 | + <name>Spring Milestones</name> |
| 97 | + <url>https://repo.spring.io/milestone</url> |
| 98 | + </repository> |
| 99 | + <repository> |
| 100 | + <id>spring-snapshots</id> |
| 101 | + <name>Spring Snapshots</name> |
| 102 | + <url>https://repo.spring.io/snapshot</url> |
| 103 | + <snapshots> |
| 104 | + <enabled>true</enabled> |
| 105 | + </snapshots> |
| 106 | + </repository> |
| 107 | + </repositories> |
| 108 | + |
| 109 | + <pluginRepositories> |
| 110 | + <pluginRepository> |
| 111 | + <id>spring-milestones</id> |
| 112 | + <name>Spring Milestones</name> |
| 113 | + <url>https://repo.spring.io/milestone</url> |
| 114 | + </pluginRepository> |
| 115 | + <pluginRepository> |
| 116 | + <id>spring-snapshots</id> |
| 117 | + <name>Spring Snapshots</name> |
| 118 | + <url>https://repo.spring.io/snapshot</url> |
| 119 | + <snapshots> |
| 120 | + <enabled>true</enabled> |
| 121 | + </snapshots> |
| 122 | + </pluginRepository> |
| 123 | + </pluginRepositories> |
| 124 | + |
| 125 | +</project> |
0 commit comments