tomcat基础镜像构建
2020-12-11
Dockerfile
FROM harbor.demo.com/jdk-8u202-baseimage:1.0.0
RUN ["mkdir","/im-svc"]
ADD tomcat /im-svc/tomcat
RUN chmod +x /im-svc/tomcat/bin/*
ENV CATALINA_HOME /im-svc/tomcat
ENV PATH $PATH:$CATALINA_HOME/bin
# 暴露端口
EXPOSE 8888
WORKDIR /im-svc/tomcat
# Launch Tomcat
CMD ["/im-svc/tomcat/bin/catalina.sh", "run"]
build.sh
#!/bin/sh
TOMCAT_VERSION=7.0.107
IMAGE_URL=harbor.demo.com/tomcat-${TOMCAT_VERSION}-baseimage:1.0.0
WORK=`pwd`
mkdir $WORK/build
unzip apache-tomcat-${TOMCAT_VERSION}.zip
mv apache-tomcat-${TOMCAT_VERSION} $WORK/build/tomcat
cp $WORK/Dockerfile $WORK/build
cd $WORK/build
sed -i 's@port="8080"@port="8888"@g' $WORK/build/tomcat/conf/server.xml
sed -i 's@CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out@CATALINA_OUT=/dev/null@' $WORK/build/tomcat/bin/catalina.sh
rm -rf $WORK/build/tomcat/webapps/{docs,examples,host-manager,manager,ROOT}
docker build --rm --no-cache -t $IMAGE_URL .
rm -rf $WORK/build
docker push $IMAGE_URL
docker rmi $IMAGE_URL