优化tomcat。tomcat8默认UTF-8编码,不用再手动配置了。映射server.xml,webapps和logs,方便用户使用。

This commit is contained in:
KennyLee 2017-01-22 16:40:26 +08:00
parent 0ba3d4e03a
commit 5d9e6ac297
12 changed files with 73 additions and 47 deletions

View File

@ -20,10 +20,6 @@ RUN tar zxf apache-tomcat-*.tar.gz && \
rm apache-tomcat-*.tar.gz && \
mv apache-tomcat* ${CATALINA_HOME}
# set config
COPY server.xml /tmp/
RUN cp -f /tmp/server.xml ${CATALINA_HOME}/conf/
# Add service
COPY tomcat /etc/init.d/
RUN chmod +x /etc/init.d/tomcat

View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -67,7 +67,7 @@
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--

View File

@ -1,4 +1,12 @@
web:
build: .
ports:
- 8080:8080
version: '2'
services:
app:
build: .
ports:
- "8080:8080"
volumes:
- ./app/webapps/:/opt/tomcat/webapps/:z
- ./config/server.xml:/opt/tomcat/conf/server.xml:ro
- ./data/logs/:/opt/tomcat/logs/:z
restart: always

View File

@ -1,6 +1,5 @@
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/java:openjdk-7-jre
# 维护者信息
MAINTAINER kennylee26 <kennylee26@gmail.com>
RUN apt-get update && \
@ -8,21 +7,14 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV TOMCAT_MAJOR_VERSION 8
ENV TOMCAT_MAJOR_VERSION '8'
ENV CATALINA_HOME /opt/tomcat
RUN curl -s -o /tmp/v.html http://mirror.bit.edu.cn/apache/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/
# INSTALL TOMCAT
RUN wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v`cat /tmp/v.html | grep "<a href=\"v"| sed -e "s/<[^>]*>//g" | awk 'END{print $1}' | sed 's:^.\(.*\).$:\1:'`/bin/apache-tomcat-`cat /tmp/v.html | grep "<a href=\"v"| sed -e "s/<[^>]*>//g" | awk 'END{print $1}' | sed 's:^.\(.*\).$:\1:'`.tar.gz && \
RUN curl -sSL http://git.oschina.net/kennylee/shell/raw/master/tomcat_download.sh | bash -s ${TOMCAT_MAJOR_VERSION} && \
tar zxf apache-tomcat-*.tar.gz && \
rm apache-tomcat-*.tar.gz && \
mv apache-tomcat* ${CATALINA_HOME} && \
rm /tmp/v.html
# set config
COPY server.xml /tmp/
RUN cp -f /tmp/server.xml ${CATALINA_HOME}/conf/
mv apache-tomcat* ${CATALINA_HOME}
# Add service
COPY tomcat /etc/init.d/

View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -67,7 +67,7 @@
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--

View File

@ -5,8 +5,8 @@ services:
ports:
- "8080:8080"
volumes:
- ./data/webapps/:/opt/tomcat/webapps/:z
environment:
- TZ=Asia/Shanghai
- ./app/webapps/:/opt/tomcat/webapps/:z
- ./config/server.xml:/opt/tomcat/conf/server.xml:ro
- ./data/logs/:/opt/tomcat/logs/:z
restart: always

View File

@ -1,6 +1,5 @@
FROM registry.cn-hangzhou.aliyuncs.com/kennylee/java:openjdk-8-jre
# 维护者信息
MAINTAINER kennylee26 <kennylee26@gmail.com>
RUN apt-get update && \
@ -8,21 +7,14 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV TOMCAT_MAJOR_VERSION 8
ENV TOMCAT_MAJOR_VERSION '8'
ENV CATALINA_HOME /opt/tomcat
RUN curl -s -o /tmp/v.html http://mirror.bit.edu.cn/apache/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/
# INSTALL TOMCAT
RUN wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v`cat /tmp/v.html | grep "<a href=\"v"| sed -e "s/<[^>]*>//g" | awk 'END{print $1}' | sed 's:^.\(.*\).$:\1:'`/bin/apache-tomcat-`cat /tmp/v.html | grep "<a href=\"v"| sed -e "s/<[^>]*>//g" | awk 'END{print $1}' | sed 's:^.\(.*\).$:\1:'`.tar.gz && \
RUN curl -sSL http://git.oschina.net/kennylee/shell/raw/master/tomcat_download.sh | bash -s ${TOMCAT_MAJOR_VERSION} && \
tar zxf apache-tomcat-*.tar.gz && \
rm apache-tomcat-*.tar.gz && \
mv apache-tomcat* ${CATALINA_HOME} && \
rm /tmp/v.html
# set config
COPY server.xml /tmp/
RUN cp -f /tmp/server.xml ${CATALINA_HOME}/conf/
mv apache-tomcat* ${CATALINA_HOME}
# Add service
COPY tomcat /etc/init.d/

View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -61,13 +61,13 @@
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
@ -77,14 +77,39 @@
redirectPort="8443" />
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
@ -140,3 +165,4 @@
</Engine>
</Service>
</Server>

View File

@ -5,8 +5,8 @@ services:
ports:
- "8080:8080"
volumes:
- ./data/webapps/:/opt/tomcat/webapps/:z
environment:
- TZ=Asia/Shanghai
- ./app/webapps/:/opt/tomcat/webapps/:z
- ./config/server.xml:/opt/tomcat/conf/server.xml:ro
- ./data/logs/:/opt/tomcat/logs/:z
restart: always