Dockerfile 文件构建docker镜像 FROM centos
MAINTAINER zhaoweifeng "zh******tech.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/ RUN tar zxf /home/jdk-8u181-linux-x64.tar.gz -C /home/JDK ENV JAVA_HOME /home/JDK/jdk1.8.0_181
ENV CATALINA_HOME /home/Tomcat/apache-tomcat-7.0.90
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin RUN mkdir Tomcat
COPY apache-tomcat-7.0.90.tar.gz /home/
RUN tar zxf /home/apache-tomcat-7.0.90.tar.gz -C /home/Tomcat && rm -rf /home/apache-tomcat-7.0.90.tar.gz ADD server.xml /home/Tomcat/apache-tomcat-7.0.90/conf/ COPY deploy_files /home/Tomcat/apache-tomcat-7.0.90/deploy_files EXPOSE 8080 WORKDIR /home/Tomcat ENTRYPOINT /home/Tomcat/apache-tomcat-7.0.90/bin/startup.sh && tail -f /home/Tomcat/apache-tomcat-7.0.90/logs/catalina.out
server.xml 部分内容 <Context path="/" reloadable="true" docBase="/home/Tomcat/apache-tomcat-7.0.90/deploy_files" workDir="/home/Tomcat/apache-tomcat-7.0.90/deploy_files" sessionCookieName="JSESSIONID1"/>
shell 脚本实现jenkins上自动构建阿里云k8s上应用 #!/bin/bash mv /mnt/workspace/deep-weifeng-bi-test/weifeng-web/target/weifeng-weifeng.war /mnt/workspace/deep-weifeng-bi-test/dockerfile/ cd /mnt/workspace/deep-weifeng-bi-test/dockerfile/ rm -rf deploy_files unzip -oq weifeng-weifeng.war -d deploy_files sudo docker build -t weifeng-bi-test -f Dockerfile.test . sudo docker login --username=***** -p ****** registry-vpc.*******liyuncs.com sudo docker tag weifeng-bi-test registry-vpc.cn-******aliyuncs.com/weifeng-system/weifeng-bi-test sudo docker push registry-vpc*******.aliyuncs.com/weifeng-system/weifeng-bi-test curl https://cs.console.aliyun.com/hook********************************I58ehpQRSBrb-JtS3yo83qMmu3AH6ptMXlXjpCUTQfClyZLbEgokE if [ $? -eq 0 ]; then
echo -e "\033[32m[ the application deep-weifeng-bi-test successfully deployed ]\033[0m" else
echo -e "\033[31m\033[01m[ the application deep-weifeng-bi-test deploy failed ]\033[0m" fi