From 8480ea9635fb0442f64ff40b04e358f7b28b2ddc Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 12 Nov 2017 15:12:19 +0200 Subject: [PATCH 1/4] Make able to run Docker tomcat image with all demo wars. --- .dockerignore | 25 +++ Dockerfile | 4 + demo-server/conf/catalina.properties | 158 +++++++++++++++++++ demo-server/{ => webapps/ROOT}/flow-logo.svg | 0 demo-server/{ => webapps/ROOT}/index.jsp | 2 +- 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 demo-server/conf/catalina.properties rename demo-server/{ => webapps/ROOT}/flow-logo.svg (100%) rename demo-server/{ => webapps/ROOT}/index.jsp (98%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e4898d773 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +* +!demo-server/ + +# https://github.com/moby/moby/issues/30018 +# Docker does not understand globs in negations as nice as it should be +# so instead of !*/target/*.war we get these: +!demo-route-menu/target/*.war +!demo-dynamic-menu/target/*.war +!demo-minesweeper-element/target/*.war +!demo-static-menu/target/*.war +!demo-todo-template/target/*.war +!demo-google-signin/target/*.war +!demo-minesweeper-polymer/target/*.war +!demo-static-menu-router/target/*.war +!demo-addressbook-polymer/target/*.war +!demo-hello-worlds/target/*.war +!demo-model-converters/target/*.war +!demo-contact-form/target/*.war +!demo-jquery-table/target/*.war +!demo-registration-form/target/*.war +!demo-textfield-component/target/*.war +!demo-web-site/target/*.war +!demo-date-field/target/*.war +!demo-minesweeper-component/target/*.war +!demo-textfield-composite/target/*.war diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..1f7951f42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM tomcat:9.0.10-jre8-alpine +COPY demo-server/ ${CATALINA_HOME}/ +COPY */target/*.war ${CATALINA_HOME}/webapps/ +RUN ln -s ${CATALINA_HOME}/webapps/$(basename ${CATALINA_HOME}/webapps/demo-flow-components-*.war .war) ${CATALINA_HOME}/webapps/components diff --git a/demo-server/conf/catalina.properties b/demo-server/conf/catalina.properties new file mode 100644 index 000000000..925f4e575 --- /dev/null +++ b/demo-server/conf/catalina.properties @@ -0,0 +1,158 @@ +# 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. + +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageAccess unless the +# corresponding RuntimePermission ("accessClassInPackage."+package) has +# been granted. +package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat. +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageDefinition unless the +# corresponding RuntimePermission ("defineClassInPackage."+package) has +# been granted. +# +# by default, no packages are restricted for definition, and none of +# the class loaders supplied with the JDK call checkPackageDefinition. +# +package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,\ +org.apache.jasper.,org.apache.naming.,org.apache.tomcat. + +# +# +# List of comma-separated paths defining the contents of the "common" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank,the JVM system loader will be used as Catalina's "common" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# +# Note: Values are enclosed in double quotes ("...") in case either the +# ${catalina.base} path or the ${catalina.home} path contains a comma. +# Because double quotes are used for quoting, the double quote character +# may not appear in a path. +common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar" + +# +# List of comma-separated paths defining the contents of the "server" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank, the "common" loader will be used as Catalina's "server" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# +# Note: Values may be enclosed in double quotes ("...") in case either the +# ${catalina.base} path or the ${catalina.home} path contains a comma. +# Because double quotes are used for quoting, the double quote character +# may not appear in a path. +server.loader= + +# +# List of comma-separated paths defining the contents of the "shared" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, +# the "common" loader will be used as Catalina's "shared" loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# Please note that for single jars, e.g. bar.jar, you need the URL form +# starting with file:. +# +# Note: Values may be enclosed in double quotes ("...") in case either the +# ${catalina.base} path or the ${catalina.home} path contains a comma. +# Because double quotes are used for quoting, the double quote character +# may not appear in a path. +shared.loader= + +# Default list of JAR files that should not be scanned using the JarScanner +# functionality. This is typically used to scan JARs for configuration +# information. JARs that do not contain such information may be excluded from +# the scan to speed up the scanning process. This is the default list. JARs on +# this list are excluded from all scans. The list must be a comma separated list +# of JAR file names. +# The list of JARs to skip may be over-ridden at a Context level for individual +# scan types by configuring a JarScanner with a nested JarScanFilter. +# The JARs listed below include: +# - Tomcat Bootstrap JARs +# - Tomcat API JARs +# - Catalina JARs +# - Jasper JARs +# - Tomcat JARs +# - Common non-Tomcat JARs +# - Test JARs (JUnit, Cobertura and dependencies) +tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\ +bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ +annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\ +jaspic-api.jar,\ +catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-storeconfig.jar,\ +catalina-tribes.jar,\ +jasper.jar,jasper-el.jar,ecj-*.jar,\ +tomcat-api.jar,tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,\ +tomcat-dbcp.jar,tomcat-jni.jar,tomcat-websocket.jar,\ +tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ +tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\ +tomcat-jdbc.jar,\ +tools.jar,\ +commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\ +commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\ +commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\ +commons-math*.jar,commons-pool*.jar,\ +jstl.jar,taglibs-standard-spec-*.jar,\ +geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\ +ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\ +jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\ +xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ +junit.jar,junit-*.jar,hamcrest-*.jar,easymock-*.jar,cglib-*.jar,\ +objenesis-*.jar,ant-launcher.jar,\ +cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\ +jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\ +xom-*.jar + +# Default list of JAR files that should be scanned that overrides the default +# jarsToSkip list above. This is typically used to include a specific JAR that +# has been excluded by a broad file name pattern in the jarsToSkip list. +# The list of JARs to scan may be over-ridden at a Context level for individual +# scan types by configuring a JarScanner with a nested JarScanFilter. +tomcat.util.scan.StandardJarScanFilter.jarsToScan=\ +log4j-web*.jar,log4j-taglib*.jar,log4javascript*.jar,slf4j-taglib*.jar + +# String cache configuration. +tomcat.util.buf.StringCache.byte.enabled=true +#tomcat.util.buf.StringCache.char.enabled=true +#tomcat.util.buf.StringCache.trainThreshold=500000 +#tomcat.util.buf.StringCache.cacheSize=5000 + +# Allow for changes to HTTP request validation +# WARNING: Using this option will expose the server to CVE-2016-6816 +#tomcat.util.http.parser.HttpParser.requestTargetAllow=| + +# Flow development mode +vaadin.productionMode=true + +# Google signin authorisation client id +vaadin.google.auth.client.id=85635090148-v10q4vim1gc77ngjb8836ikm0dvvefl9.apps.googleusercontent.com diff --git a/demo-server/flow-logo.svg b/demo-server/webapps/ROOT/flow-logo.svg similarity index 100% rename from demo-server/flow-logo.svg rename to demo-server/webapps/ROOT/flow-logo.svg diff --git a/demo-server/index.jsp b/demo-server/webapps/ROOT/index.jsp similarity index 98% rename from demo-server/index.jsp rename to demo-server/webapps/ROOT/index.jsp index 0c5435f2f..485294315 100644 --- a/demo-server/index.jsp +++ b/demo-server/webapps/ROOT/index.jsp @@ -34,7 +34,7 @@ Map> stableVersions = new HashMap<>(); Map> snapshotVersions = new HashMap<>(); // Java 1.7 -File[] files = new File("/home/dev/tomcat/webapps/").listFiles(); +File[] files = new File("webapps").listFiles(); if (files != null) { for (File f : files) { if (f.isDirectory()) { From a9bbebdeb3acb013e282dd6aafde91c3287b9402 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 5 Jul 2018 11:02:57 +0300 Subject: [PATCH 2/4] Add a script to create a Docker container and run it. --- create_and_run_demos_container.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 create_and_run_demos_container.sh diff --git a/create_and_run_demos_container.sh b/create_and_run_demos_container.sh new file mode 100755 index 000000000..9a5649857 --- /dev/null +++ b/create_and_run_demos_container.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +docker build -t flow-demos . +docker rm flow-demos +docker run -p 8080:8080 -d --name flow-demos flow-demos From aa4429d0a84baa58b484d2cba7c083dfb9ad6232 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 5 Jul 2018 11:24:31 +0300 Subject: [PATCH 3/4] Use strict configuration --- demo-server/conf/catalina.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/demo-server/conf/catalina.properties b/demo-server/conf/catalina.properties index 925f4e575..ef323c3ec 100644 --- a/demo-server/conf/catalina.properties +++ b/demo-server/conf/catalina.properties @@ -156,3 +156,8 @@ vaadin.productionMode=true # Google signin authorisation client id vaadin.google.auth.client.id=85635090148-v10q4vim1gc77ngjb8836ikm0dvvefl9.apps.googleusercontent.com + + +# Be strict about web-fragment.xml contents +# https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html#Specifications +org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true From 5733710caa6e8e0b8dbef022ee6c57afb4df9091 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 5 Jul 2018 13:44:06 +0300 Subject: [PATCH 4/4] Make the index file work for both docker image and flow.app.fi --- demo-server/webapps/ROOT/index.jsp | 73 ++++++++++++++++-------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/demo-server/webapps/ROOT/index.jsp b/demo-server/webapps/ROOT/index.jsp index 485294315..6b7a12838 100644 --- a/demo-server/webapps/ROOT/index.jsp +++ b/demo-server/webapps/ROOT/index.jsp @@ -24,6 +24,7 @@ <%@page import="java.io.File" %> <%@page import="java.io.FileInputStream" %> <%@page import="java.util.ArrayList" %> +<%@page import="java.util.Arrays" %> <%@page import="java.util.Collections" %> <%@page import="java.util.HashMap" %> <%@page import="java.util.List" %> @@ -34,45 +35,47 @@ Map> stableVersions = new HashMap<>(); Map> snapshotVersions = new HashMap<>(); // Java 1.7 -File[] files = new File("webapps").listFiles(); -if (files != null) { - for (File f : files) { - if (f.isDirectory()) { - String nameAndVersion = f.getName(); - if (nameAndVersion.startsWith("demo-")) { - File manifest = new File(f, "META-INF/MANIFEST.MF"); - if (manifest.isFile()) { - Manifest mf = new Manifest(new FileInputStream(manifest)); - String title = mf.getMainAttributes().getValue("Implementation-Title"); - if (title != null) { - String version = mf.getMainAttributes().getValue("Implementation-Version"); - if (version == null) { - int versionStarts = nameAndVersion.lastIndexOf("-"); - if (nameAndVersion.endsWith("-SNAPSHOT")) { - versionStarts = nameAndVersion.lastIndexOf("-", versionStarts - 1); +for (String applicationLocation: Arrays.asList("tomcat/webapps", "webapps")) { + File[] files = new File(applicationLocation).listFiles(); + if (files != null) { + for (File f : files) { + if (f.isDirectory()) { + String nameAndVersion = f.getName(); + if (nameAndVersion.startsWith("demo-")) { + File manifest = new File(f, "META-INF/MANIFEST.MF"); + if (manifest.isFile()) { + Manifest mf = new Manifest(new FileInputStream(manifest)); + String title = mf.getMainAttributes().getValue("Implementation-Title"); + if (title != null) { + String version = mf.getMainAttributes().getValue("Implementation-Version"); + if (version == null) { + int versionStarts = nameAndVersion.lastIndexOf("-"); + if (nameAndVersion.endsWith("-SNAPSHOT")) { + versionStarts = nameAndVersion.lastIndexOf("-", versionStarts - 1); + } + version = nameAndVersion.substring(versionStarts + 1); } - version = nameAndVersion.substring(versionStarts + 1); - } - String name = nameAndVersion.substring(0, nameAndVersion.indexOf(version) - 1); - List names; - String sourceLink; + String name = nameAndVersion.substring(0, nameAndVersion.indexOf(version) - 1); + List names; + String sourceLink; - if (version.endsWith("-SNAPSHOT")) { - names = snapshotVersions.get(version); - if (names == null) { - names = new ArrayList<>(); - snapshotVersions.put(version, names); - } - sourceLink = "https://github.com/vaadin/flow-demo/tree/master/" + name; - } else { - names = stableVersions.get(version); - if (names == null) { - names = new ArrayList<>(); - stableVersions.put(version, names); + if (version.endsWith("-SNAPSHOT")) { + names = snapshotVersions.get(version); + if (names == null) { + names = new ArrayList<>(); + snapshotVersions.put(version, names); + } + sourceLink = "https://github.com/vaadin/flow-demo/tree/master/" + name; + } else { + names = stableVersions.get(version); + if (names == null) { + names = new ArrayList<>(); + stableVersions.put(version, names); + } + sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name; } - sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name; + names.add("
  • " + title + " (sources)
  • "); } - names.add("
  • " + title + " (sources)
  • "); } } }