Skip to content

Instantly share code, notes, and snippets.

@lanhuai
Last active March 15, 2017 10:26
Show Gist options
  • Save lanhuai/a25ffb5e2792b55ea228a6946ebee7ce to your computer and use it in GitHub Desktop.
Save lanhuai/a25ffb5e2792b55ea228a6946ebee7ce to your computer and use it in GitHub Desktop.
Tomcat 8 and alpine docker Dockerfile
FROM anapsix/alpine-java:8_jdk_unlimited
MAINTAINER lanhuai<[email protected]>
# alpine 的时区配置不起作用,主要依靠JDK的参数设置
# -Duser.language=zh -Duser.country=CN -Duser.timezone=Asia/Shanghai
# Expose web port
EXPOSE 8080
# Tomcat Version
ENV TOMCAT_VERSION_MAJOR 8
ENV TOMCAT_VERSION_FULL 8.5.12
# Download and install
# Add USTC repo
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
#
# Set timezone
&& apk add -U tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& apk del tzdata \
#cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime
#echo "Europe/Brussels" > /etc/timezone
#
# Sepcify ntp server
# && sed -i 's/pool.ntp.org/cn.pool.ntp.org/' /etc/init.d/ntpd \
&& apk add -U curl &&\
curl -LO https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_VERSION_MAJOR}/v${TOMCAT_VERSION_FULL}/bin/apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz &&\
curl -LO https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_VERSION_MAJOR}/v${TOMCAT_VERSION_FULL}/bin/apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz.md5 &&\
md5sum -c apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz.md5 &&\
gunzip -c apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz | tar -xf - -C /opt &&\
rm -f apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz apache-tomcat-${TOMCAT_VERSION_FULL}.tar.gz.md5 &&\
ln -s /opt/apache-tomcat-${TOMCAT_VERSION_FULL} /opt/tomcat &&\
rm -rf /opt/tomcat/webapps/examples /opt/tomcat/webapps/docs /opt/tomcat/webapps/ROOT &&\
apk del curl &&\
rm -rf /var/cache/apk/*
# Configuration
#ADD tomcat-users.xml /opt/tomcat/conf/
#RUN sed -i 's/52428800/5242880000/g' /opt/tomcat/webapps/manager/WEB-INF/web.xml
# Set environment
ENV CATALINA_HOME /opt/tomcat
ENV PATH $PATH:$CATALINA_HOME/bin
#ENV TZ "Asia/Shanghai"
#WORKDIR /opt/tomcat
# 启动 Tomcat
CMD ${CATALINA_HOME}/bin/catalina.sh run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment