Dockerfile 构建后端springboot应用并用shell脚本实现jenkins自动构建
Posted Oops!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dockerfile 构建后端springboot应用并用shell脚本实现jenkins自动构建相关的知识,希望对你有一定的参考价值。
Dockerfile 文件构建docker镜像 FROM centos MAINTAINER zh*****eng "z*******ch.cn" ENV LANG en_US.UTF-8 RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo ‘Asia/Shanghai‘ >/etc/timezone WORKDIR /home RUN mkdir JDK COPY jdk-8u181-linux-x64.tar.gz /home/ COPY weifeng.jar /home/ RUN tar zxf /home/jdk-8u181-linux-x64.tar.gz -C /home/JDK ENV JAVA_HOME /home/JDK/jdk1.8.0_181 ENV PATH $PATH:$JAVA_HOME/bin EXPOSE 8080 WORKDIR /home/JDK ENTRYPOINT ["java","-jar","/home/weifeng.jar"," -Xms512m","-Xmx2048m","--spring.profiles.active=dev","--server.port=8080"]
shell 脚本实现jenkins上自动构建阿里云k8s上应用 #!/bin/bash mv /mnt/workspace/weifeng-dev/weifeng-web/target/weifeng.jar /mnt/workspace/weifeng-dev/dockerfile/ cd /mnt/workspace/weifeng-dev/dockerfile/ sudo docker build -t weifeng-dev -f Dockerfile.dev . sudo docker login --username=**** -p ******* registry-vpc.*****.aliyuncs.com sudo docker tag weifeng-dev registry-vpc.******.aliyuncs.com/weifeng-system/weifeng-dev sudo docker push registry-vpc.******.aliyuncs.com/weifeng-system/weifeng-dev curl https://cs.console.aliyun.com/hook/t**********n-uzNGKvYTOAgQrWw2p7rQpfBsIX7_Chii7g51y5zbOsu_F8whppyT20ZBmX8Dc2esYw09s if [ $? -eq 0 ]; then echo -e " 33[32m[ the application weifeng-dev successfully deployed ] 33[0m" else echo -e " 33[31m 33[01m[ the application weifeng-dev deploy failed ] 33[0m" fi
以上是关于Dockerfile 构建后端springboot应用并用shell脚本实现jenkins自动构建的主要内容,如果未能解决你的问题,请参考以下文章
Docker——使用Dockerfile构建SpringBoot项目(打包 & 部署 & 运行)
Dockerfile 构建后端tomcat应用并用shell脚本实现jenkins自动构建
使用Dockerfile为SpringBoot应用构建Docker镜像
Dockerfile构建Springboot工程镜像并运行(命令详解)