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