首先创建一个Dockerfile
编写Dockerfile的信息
FROM java:8
MAINTAINER clarkshi@xxx.com
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENV ACTIVE="pre"
ENV loggingpath="/zhibo/logs"
ADD target/ShuZiZhiBo-0.0.1.jar ShuZiZhiBo.jar
ENTRYPOINT ["java" ,"-Dspring.profiles.active=${ACTIVE}","-Dlogging.path=${loggingpath}", "-jar","/ShuZiZhiBo.jar"]
ENV ACTIVE="pre"设置推送的环境
ENV loggingpath设置生成的日志
登陆腾讯云 镜像仓库,创建一个镜像地址
创建后,记住【仓库地址】和【命名空间】
pom文件编辑(这里需提前创建访问凭证)
<plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.4.13</version> <executions> <execution> <id>harbor</id> <goals> <goal>build</goal> <goal>push</goal> </goals> </execution> </executions> <configuration> <!-- 腾讯云镜像仓库地址 --> <!-- <repository>仓库地址预发布环境</repository>--> <!-- <repository>仓库地址正式环境</repository>--> <repository>仓库地址-测试环境</repository> <tag>${project.version}</tag> <useMavenSettingsForAuth>true</useMavenSettingsForAuth> <!-- 构建的用户凭证 --> <username>10002我删除了一半</username> <password>eyxxxxx我删除了一大坨/password> <buildArgs> <!-- 构建的jar包文件名 --> <JAR_FILE>${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin>
然后打开右边的maven点击plugins里面的dockerfile,选择build和push就能自动推送了
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/31760