dockerFile创建Centos7, jdk8, tomcat8, maven3镜像

FROM centos:7
MAINTAINER Mr "yangtengfeiczb@dingtalk.com"

#RUN apt-get update
#RUN apt-get install wget

RUN yum -y install wget

WORKDIR /usr

#安装JDK
RUN mkdir /usr/local/jdk
RUN wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"  -P /usr/local/jdk http://yilong-common.oss-cn-shanghai.aliyuncs.com/lib/jdk-8u211-linux-x64.tar.gz
RUN tar -zxvf /usr/local/jdk/jdk-8u211-linux-x64.tar.gz -C /usr/local/jdk
RUN rm -rf /usr/local/jdk/jdk-8u211-linux-x64.tar.gz

#安装tomcat
RUN mkdir /usr/local/tomcat
RUN wget -P /usr/local/tomcat http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz
RUN tar -zxvf /usr/local/tomcat/apache-tomcat-8.5.38.tar.gz -C /usr/local/tomcat
RUN rm -rf /usr/local/tomcat/apache-tomcat-8.5.38.tar.gz

#安装maven
RUN mkdir /usr/local/maven
RUN wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
RUN tar -zxvf /usr/apache-maven-3.6.1-bin.tar.gz -C /usr/local/maven
RUN rm -rf /usr/apache-maven-3.6.1-bin.tar.gz

#设置环境变量
ENV JAVA_HOME /usr/local/jdk/jdk1.8.0_211
ENV JRE_HOME $JAVA_HOME/jre
ENV CATALINA_HOME /usr/local/tomcat/apache-tomcat-8.5.38
ENV M2_HOME /usr/local/maven/apache-maven-3.6.1
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$M2_HOME/bin

#创建项目目录
RUN mkdir /usr/local/webapp

#ADD  源宿主机路径  目标镜像路径; (ADD会解压和覆盖, cp不会   cp  源宿主机路径  目标镜像路径)
ADD manager-parent /usr/local/webapp

#maven的settings.xml
ADD settings.xml /usr/local/maven/apache-maven-3.6.1/conf

#tomcat的server.xml 和 tomcat-users.xml 和 setenv.sh
ADD server.xml /usr/local/tomcat/apache-tomcat-8.5.38/conf
ADD tomcat-users.xml /usr/local/tomcat/apache-tomcat-8.5.38/conf
ADD setenv.sh /usr/local/tomcat/apache-tomcat-8.5.38/bin

#打包项目并拷贝到tomcat webapps目录
RUN cd /usr/local/webapp \
    && mvn clean \
    && mvn package -P prod \
    && cp /usr/local/webapp/manager-web/target/manager-web.war /usr/local/tomcat/apache-tomcat-8.5.38/webapps

#开启内部服务端口
EXPOSE 8080

#启动tomcat服务器
CMD ["./usr/local/tomcat/apache-tomcat-8.5.38/bin/catalina.sh","run"]

 

posted @ 2019-05-28 18:18  Peter.Jones  阅读(1120)  评论(0编辑  收藏  举报