From 99e9272f179136ca50de57f1816842f060f245c0 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sun, 9 Dec 2018 14:52:20 +0800 Subject: [PATCH] =?UTF-8?q?#170=20=E4=BD=BF=E7=94=A8tomcat=20slim=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contact-center/.dockerignore | 9 ++++--- contact-center/Dockerfile | 25 +++++-------------- contact-center/admin/build.sh | 5 +++- contact-center/admin/push.sh | 16 ++++++++++++ contact-center/config/tomcat.context.xml | 31 ++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 24 deletions(-) create mode 100755 contact-center/admin/push.sh create mode 100644 contact-center/config/tomcat.context.xml diff --git a/contact-center/.dockerignore b/contact-center/.dockerignore index 01004263..d0999061 100644 --- a/contact-center/.dockerignore +++ b/contact-center/.dockerignore @@ -1,4 +1,5 @@ -./app/target/ -./logs/ -./tmp/ -./data/ +app/target +!app/target/contact-center-*.war.original +logs/ +tmp/ +data/ diff --git a/contact-center/Dockerfile b/contact-center/Dockerfile index a2dd9e07..d6662772 100644 --- a/contact-center/Dockerfile +++ b/contact-center/Dockerfile @@ -1,4 +1,4 @@ -FROM chatopera/java:1.0.0 +FROM tomcat:8.5.35-slim MAINTAINER Hai Liang Wang ARG VCS_REF @@ -20,25 +20,12 @@ ENV LANG C.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL C.UTF-8 - -# set ENVs -ENV JAVA_HOME=/opt/java-8-oracle -ENV MAVEN_HOME=/opt/apache-maven -ENV TOMCAT_HOME=/opt/apache-tomcat -ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin - # create dirs RUN /bin/bash -c "mkdir -p /{data,logs}" -# build WAR -COPY app /app -COPY config /config -WORKDIR /app -RUN mvn clean package && \ - rm -rf /opt/apache-tomcat/webapps/ROOT && \ - cp target/contact-center-*.war.original /opt/apache-tomcat/webapps/ROOT.war && \ - rm -rf /app && \ - rm -rf /root/.m2 +# copy WAR +RUN rm -rf /usr/local/tomcat/webapps/* +COPY ./app/target/contact-center-3.9.0.war.original /usr/local/tomcat/webapps/ROOT.war +COPY ./config/tomcat.context.xml /usr/local/tomcat/conf/context.xml -EXPOSE 8030-8090 9200 9300 -CMD ["/opt/apache-tomcat/bin/catalina.sh", "run"] +EXPOSE 8030-8090 9200 9300 \ No newline at end of file diff --git a/contact-center/admin/build.sh b/contact-center/admin/build.sh index 981e8681..8fb05ef5 100755 --- a/contact-center/admin/build.sh +++ b/contact-center/admin/build.sh @@ -6,7 +6,6 @@ # constants baseDir=$(cd `dirname "$0"`;pwd) appHome=$baseDir/.. -registry=registry.chatopera.com imagename=chatopera/contact-center PACKAGE_VERSION=1.0.0 # functions @@ -14,6 +13,10 @@ PACKAGE_VERSION=1.0.0 # main [ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return set -x +# package +$baseDir/package.sh + +# build cd $appHome docker build --build-arg VCS_REF=`git rev-parse --short HEAD` --force-rm=true --tag $imagename:$PACKAGE_VERSION . docker tag $imagename:$PACKAGE_VERSION $imagename:develop diff --git a/contact-center/admin/push.sh b/contact-center/admin/push.sh new file mode 100755 index 00000000..06b62cf9 --- /dev/null +++ b/contact-center/admin/push.sh @@ -0,0 +1,16 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +imagename=chatopera/contact-center +PACKAGE_VERSION=1.0.0 + +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +docker push $imagename:$PACKAGE_VERSION +docker push $imagename:develop diff --git a/contact-center/config/tomcat.context.xml b/contact-center/config/tomcat.context.xml new file mode 100644 index 00000000..41a32025 --- /dev/null +++ b/contact-center/config/tomcat.context.xml @@ -0,0 +1,31 @@ + + + + + + + + WEB-INF/web.xml + ${catalina.base}/conf/web.xml + + + + +