Name: tomcat-runtime
Owner: Google Cloud Platform
Description: Google Cloud Platform Apache Tomcat Docker image
Created: 2015-06-15 20:38:00.0
Updated: 2018-04-01 23:48:41.0
Pushed: 2018-04-12 03:11:16.0
Size: 207
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This Project is Archived
This repository contains the source for the Google-maintained Tomcat docker image.
Simply choose the Java runtime with Tomcat as the server preference in app.yaml
.
ime: java
flex
ime_config:
rver: tomcat8
Then you can deploy using the gcloud beta app deploy
command. Note that the “beta” command is currently required.
Specify a custom runtime in app.yaml
.
ime: custom
flex
Then create a Dockerfile
that uses the Tomcat runtime image as specified in Other platforms.
Create a Dockerfile
based on the image and add your application WAR:
gcr.io/google-appengine/tomcat
your-application.war $APP_DESTINATION_WAR
You can also use an exploded-war:
your-application $APP_DESTINATION_EXPLODED_WAR
The Tomcat instance can be configured through the environment variable TOMCAT_PROPERTIES
which is
a comma-separated list of name=value
pairs appended to catalina.properties
.
For security purposes it is recommended to start the Tomcat instance using the tomcat
user.
You can do so by adding USER tomcat
at the end of your Dockerfile.
gcr.io/google-appengine/tomcat
your-application.war $APP_DESTINATION_WAR
chown tomcat:tomcat $APP_DESTINATION_WAR
tomcat
If you are using an exploded-war, then use the $APP_DESTINATION_EXPLODED_WAR
environment variable instead.
This image can be configured to store Tomcat sessions in the Google Cloud Datastore which allows multiple instances of Tomcat to share sessions.
You can enable this feature by adding distributed-sessions
to the list of optional modules, which is specified in the TOMCAT_MODULES_ENABLE
environment variable.
The distributed sessions module can be configured through the environment variable TOMCAT_PROPERTIES
.
| Property | Description | Default | |—|—|—| | gcp.distributed-sessions.namespace | Namespace to use in the Datastore. | tomcat-gcp-persistent-session | | gcp.distributed-sessions.sessionKind | Name of the entity used to store sessions in the Datastore. | TomcatGCloudSession | | gcp.distributed-sessions.uriExcludePattern | Pattern specifying which URI to ignore when persisting sessions. | null | | gcp.distributed-sessions.enableTrace | Register the operations of the module in Stackdriver Trace. (The Trace module must also be active) | false |
For example on Google App Engine:
variables:
MCAT_MODULES_ENABLE: distributed-sessions
MCAT_PROPERTIES: gcp.distributed-sessions.uriExcludePattern=^/_ah/.*
If you are using the runtime outside of GCP, you will want to make sure that your application has access to the Datastore. In this case, check out the Google Cloud Authentication guide.
The trace module sends information about requests (such as latency) to the Stackdriver Trace service.
To enable this module add stackdriver-trace
to the list of enabled modules.
variables:
MCAT_MODULES_ENABLE: stackdriver-trace
The following configuration is available through the the environment variable TOMCAT_PROPERTIES
.
| Property | Description | Default | |—|—|—| | gcp.stackdriver-trace.scheduledDelay | The traces are grouped before being sent to the Stackdriver service, this is the maximum time in seconds a trace can be buffered| 15 |
When you are using this module outside of GCP you need to provide credentials through Google Cloud Authentication.
When the Tomcat runtime is running on Google App Engine flexible environment all output to stdout/stderr is forwarded to Stackdriver Logging and available in the Cloud Console Log Viewer.
However more detailed and integrated logs are available if the Stackdriver Logging mechanism is used directly.
To take advantage of this integration, add the Google Cloud Java Client for Logging
to your dependencies and provide a Java Util Logging configuration file (logging.properties
) as part of the resources of the application (classes/logging.properties
) with the following content:
lers=com.google.cloud.logging.LoggingHandler
tional configuration
el=FINE
google.cloud.logging.LoggingHandler.level=FINE
google.cloud.logging.LoggingHandler.log=gae_app.log
google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s
Tomcat offers the possibility to use GZIP compression.
To take advantage of this feature set the property tomcat.server.connector.compression
to on
:
variables:
MCAT_PROPERTIES: tomcat.server.connector.compression=on
You can also specify a numerical value indicating the minimal amount of data (in bytes) before using compression.
Detailed documentation can be found in the Tomcat documentation,
at the attribute compression
.