feat(新增): 使用harbor推送到私有库并打包

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-29 21:40:34 +08:00
parent 40a6a8d646
commit d864418faf
15 changed files with 348 additions and 10 deletions

View File

@ -61,4 +61,16 @@
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
FROM openjdk:18
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
@ -17,4 +18,4 @@ COPY target/*.jar /home/bunny/app.jar
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080
EXPOSE 8501

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -67,6 +69,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
FROM openjdk:18
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
@ -17,4 +18,4 @@ COPY target/*.jar /home/bunny/app.jar
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080
EXPOSE 8500

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -59,6 +61,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,21 @@
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# 设置时区,构建镜像时执行的命令
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
# 设定工作目录
WORKDIR /home/bunny
# 复制jar包
COPY target/*.jar /home/bunny/app.jar
#启动容器时的进程
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8513

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -31,6 +33,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
FROM openjdk:18
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
@ -17,4 +18,4 @@ COPY target/*.jar /home/bunny/app.jar
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080
EXPOSE 8510

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -41,6 +43,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,20 @@
FROM openjdk:18
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# 设置时区,构建镜像时执行的命令
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
# 设定工作目录
WORKDIR /home/bunny
# 复制jar包
COPY target/*.jar /home/bunny/app.jar
#启动容器时的进程
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -36,6 +38,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
FROM openjdk:18
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
@ -17,4 +18,4 @@ COPY target/*.jar /home/bunny/app.jar
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080
EXPOSE 8511

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -27,6 +29,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
FROM openjdk:18
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
@ -17,4 +18,4 @@ COPY target/*.jar /home/bunny/app.jar
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080
EXPOSE 8512

View File

@ -14,6 +14,8 @@
<url>https://maven.apache.org</url>
<properties>
<docker.repostory>192.168.1.4:1100</docker.repostory>
<docker.registry.name>spzx</docker.registry.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -27,6 +29,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<execution>
<id>build-image</id>
<!--将插件绑定在package这个phase(阶段)上。也就是说用户只需执行mvn package就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!-- 配置docker主机地址 -->
<dockerHost>http://192.168.1.4:2375</dockerHost>
<!--指定生成的镜像名-->
<imageName>
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
</imageName>
<!-- 指定 dockerfile 路径-->
<dockerDirectory>${project.basedir}</dockerDirectory>
<!-- 是否跳过docker构建 -->
<skipDockerBuild>false</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
</project>