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/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 diff --git a/demo-server/conf/catalina.properties b/demo-server/conf/catalina.properties new file mode 100644 index 000000000..ef323c3ec --- /dev/null +++ b/demo-server/conf/catalina.properties @@ -0,0 +1,163 @@ +# 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 + + +# 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 diff --git a/demo-server/index.jsp b/demo-server/index.jsp deleted file mode 100644 index 0c5435f2f..000000000 --- a/demo-server/index.jsp +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - -<%@page import="java.io.File" %> -<%@page import="java.io.FileInputStream" %> -<%@page import="java.util.ArrayList" %> -<%@page import="java.util.Collections" %> -<%@page import="java.util.HashMap" %> -<%@page import="java.util.List" %> -<%@page import="java.util.Map" %> -<%@page import="java.util.jar.Manifest" %> -<% -Map> stableVersions = new HashMap<>(); -Map> snapshotVersions = new HashMap<>(); - -// Java 1.7 -File[] files = new File("/home/dev/tomcat/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); - } - version = nameAndVersion.substring(versionStarts + 1); - } - 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); - } - sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name; - } - names.add("
  • " + title + " (sources)
  • "); - } - } - } - } - } -} - -out.println("Flow documentation"); -out.println(""); - -List sortedStableVersions = new ArrayList<>(stableVersions.keySet()); -if (!sortedStableVersions.isEmpty()) { - Collections.sort(sortedStableVersions); - String latestStable = sortedStableVersions.get(sortedStableVersions.size() - 1); - out.println(""+latestStable+""); - out.println("
      "); - - List demos = stableVersions.get(latestStable); - Collections.sort(demos); - for (String link : demos) { - out.println(link); - } - out.println("
    "); -} - -List sortedSnapshotVersions = new ArrayList<>(snapshotVersions.keySet()); -if (!sortedSnapshotVersions.isEmpty()) { - Collections.sort(sortedSnapshotVersions); - String latestSnapshot = sortedSnapshotVersions.get(sortedSnapshotVersions.size() - 1); - out.println(""+latestSnapshot+""); - out.println("
      "); - - List demos = snapshotVersions.get(latestSnapshot); - Collections.sort(demos); - for (String link : demos) { - out.println(link); - } - out.println("
    "); -} - -%> - - 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/webapps/ROOT/index.jsp b/demo-server/webapps/ROOT/index.jsp new file mode 100644 index 000000000..6b7a12838 --- /dev/null +++ b/demo-server/webapps/ROOT/index.jsp @@ -0,0 +1,123 @@ + + + + + + +<%@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" %> +<%@page import="java.util.Map" %> +<%@page import="java.util.jar.Manifest" %> +<% +Map> stableVersions = new HashMap<>(); +Map> snapshotVersions = new HashMap<>(); + +// Java 1.7 +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); + } + 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); + } + sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name; + } + names.add("
  • " + title + " (sources)
  • "); + } + } + } + } + } + } +} + +out.println("Flow documentation"); +out.println(""); + +List sortedStableVersions = new ArrayList<>(stableVersions.keySet()); +if (!sortedStableVersions.isEmpty()) { + Collections.sort(sortedStableVersions); + String latestStable = sortedStableVersions.get(sortedStableVersions.size() - 1); + out.println(""+latestStable+""); + out.println("
      "); + + List demos = stableVersions.get(latestStable); + Collections.sort(demos); + for (String link : demos) { + out.println(link); + } + out.println("
    "); +} + +List sortedSnapshotVersions = new ArrayList<>(snapshotVersions.keySet()); +if (!sortedSnapshotVersions.isEmpty()) { + Collections.sort(sortedSnapshotVersions); + String latestSnapshot = sortedSnapshotVersions.get(sortedSnapshotVersions.size() - 1); + out.println(""+latestSnapshot+""); + out.println("
      "); + + List demos = snapshotVersions.get(latestSnapshot); + Collections.sort(demos); + for (String link : demos) { + out.println(link); + } + out.println("
    "); +} + +%> + +