Author: remm Date: Thu Nov 29 14:29:57 2018 New Revision: 1847725 URL: http://svn.apache.org/viewvc?rev=1847725&view=rev Log: As requested, add the packaging-using-Maven as well as the corresponding (much simpler than the official one) dockerfile. To be refined most likely.
Added: tomcat/trunk/res/tomcat-maven/ tomcat/trunk/res/tomcat-maven/Dockerfile (with props) tomcat/trunk/res/tomcat-maven/README.md (with props) tomcat/trunk/res/tomcat-maven/pom.xml (with props) Modified: tomcat/trunk/webapps/docs/changelog.xml Added: tomcat/trunk/res/tomcat-maven/Dockerfile URL: http://svn.apache.org/viewvc/tomcat/trunk/res/tomcat-maven/Dockerfile?rev=1847725&view=auto ============================================================================== --- tomcat/trunk/res/tomcat-maven/Dockerfile (added) +++ tomcat/trunk/res/tomcat-maven/Dockerfile Thu Nov 29 14:29:57 2018 @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM openjdk:8-jre-alpine +VOLUME /tmp + +USER root +RUN mkdir -m 777 -p /deployments + +ADD target/tomcat-maven-1.0.jar /deployments/app.jar +ADD conf /deployments/conf +ADD webapps /deployments/webapps + +WORKDIR /deployments + +ARG namespace=myproject +ENV KUBERNETES_NAMESPACE=$namespace +ARG port=8080 +EXPOSE $port + +RUN sh -c 'touch app.jar' +ENV JAVA_OPTS="-Dcatalina.base=. -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=conf/logging.properties -Djava.security.egd=file:/dev/urandom" +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar app.jar" ] + Propchange: tomcat/trunk/res/tomcat-maven/Dockerfile ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/trunk/res/tomcat-maven/README.md URL: http://svn.apache.org/viewvc/tomcat/trunk/res/tomcat-maven/README.md?rev=1847725&view=auto ============================================================================== --- tomcat/trunk/res/tomcat-maven/README.md (added) +++ tomcat/trunk/res/tomcat-maven/README.md Thu Nov 29 14:29:57 2018 @@ -0,0 +1,74 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> + +# Apache Tomcat distribution for Apache Maven + +## Configuration + +Configuration is located in `conf/server.xml`, `conf/web.xml`, `conf/logging.properties`, all other configuration files, resources and context files are located in `conf`, identical to standalone Tomcat. + +## Building + +### Maven build + +Update Tomcat version number in the `pom.xml`, customize Tomcat components in the dependencies to keep the ones needed (only the main `tomcat-catalina` is mandatory). Custom Tomcat components sources can be added to the usual Maven build path and will be included in the package that is built. +``` +mvn clean; mvn package +``` + +### Docker build + +``` +docker build -t apache/tomcat-maven:1.0 -f ./Dockerfile . +``` +Docker build arguments include `namepsace` (default is `myproject`) and `port` which should match the Tomcat port in `server.xml` (default is `8080`). Other ports that need to be exposed can be added in the `Dockerfile` as needed. Webapps should be added to the `webapps` folder where they will be auto deployed by the host if using the defaults. Otherwise, the `Dockerfile` command line can be edited like below to include the necesary resources and command line arguments to run a single or multiple hardcoded web applications. + +## Running + +Add a webapp as folder mywebapp (for this example, or specify another path), or a path from which a configured Host will auto deploy +``` +--path: Specify a path the wepapp will use +--war: Add the spcified path (directory or war) as a webapp (if no path has been specified, it will be the root webapp) +``` + +The JULI logging manager configuration is optional but makes logging more readable and configurable: +`-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=conf/logging.properties` +The default JULI configuration uses `catalina.base`, so specifying the system property with `-Dcatalina.base=.` is also useful. + +### Command line example with a single root webapp + +``` +java -Dcatalina.base=. -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=conf/logging.properties -jar target/tomcat-maven-1.0.jar --war myrootwebapp +``` + +### Command line example with three webapps + +``` +java -Dcatalina.base=. -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=conf/logging.properties -jar target/tomcat-maven-1.0.jar --war myrootwebapp --path /path1 --war mywebapp1 --path /path2 --war mywebapp2 +``` + +## Deployment + +If using the Kubernetes cloud clustering membership provider, the pod needs to have the persmission to view other pods. For exemple with Openshift, this is done with: +``` +oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q) +``` + Propchange: tomcat/trunk/res/tomcat-maven/README.md ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/trunk/res/tomcat-maven/pom.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/res/tomcat-maven/pom.xml?rev=1847725&view=auto ============================================================================== --- tomcat/trunk/res/tomcat-maven/pom.xml (added) +++ tomcat/trunk/res/tomcat-maven/pom.xml Thu Nov 29 14:29:57 2018 @@ -0,0 +1,105 @@ +<?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 + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-maven</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <mainClass>org.apache.catalina.startup.Tomcat</mainClass> + <tomcat.version>9.0.14</tomcat.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-catalina</artifactId> + <version>${tomcat.version}</version> + </dependency> + <!-- Optional: Jasper --> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-jasper</artifactId> + <version>${tomcat.version}</version> + </dependency> + <!-- Optional: Clustering --> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-catalina-ha</artifactId> + <version>${tomcat.version}</version> + </dependency> + <!-- Optional: Websockets --> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-websocket</artifactId> + <version>${tomcat.version}</version> + </dependency> + <!-- Optional: DBCP based pool --> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-dbcp</artifactId> + <version>${tomcat.version}</version> + </dependency> + <!-- Optional: Store configuration listener --> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-storeconfig</artifactId> + <version>${tomcat.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Build any extra classes for your custom Tomcat components if needed --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <createDependencyReducedPom>false</createDependencyReducedPom> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>${mainClass}</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: tomcat/trunk/res/tomcat-maven/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1847725&r1=1847724&r2=1847725&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Nov 29 14:29:57 2018 @@ -226,6 +226,10 @@ <fix> Include Korean translations in the standard Tomcat distribution. (markt) </fix> + <add> + Add a packaging method for Tomcat using Maven, as well as a container + build file for it. (remm) + </add> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org