Dockerfile 构建后端tomcat应用并用shell脚本实现jenkins自动构建

Posted Oops!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dockerfile 构建后端tomcat应用并用shell脚本实现jenkins自动构建相关的知识,希望对你有一定的参考价值。

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 "33[32m[ the application deep-weifeng-bi-test successfully deployed  ]33[0m"

else
    echo -e "33[31m33[01m[ the application deep-weifeng-bi-test deploy failed  ]33[0m"

fi

  

 

以上是关于Dockerfile 构建后端tomcat应用并用shell脚本实现jenkins自动构建的主要内容,如果未能解决你的问题,请参考以下文章

dockerfile构建Nginx,Tomcat镜像

dockerfile构建Nginx,Tomcat镜像

dockerfile构建Nginx,Tomcat镜像

dockerfile构建Nginx,Tomcat镜像

dockerfile构建自定义tomcat容器

dockerfile构建自定义tomcat容器