From 9d77e1d221c36edb70035e1de00b3a599432b820 Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Wed, 15 May 2019 12:09:31 +0200 Subject: [PATCH 01/11] Knot.x container running with environment, fixed #61 --- .../httpd/conf/vhost/knotx.example.com.conf | 7 + ....knotx.fragments.handler.api.ActionFactory | 10 + .../environment/knotx/conf/application.conf | 12 ++ .../environment/knotx/conf/bootstrap.json | 15 ++ .../knotx/conf/default-cluster.xml | 171 ++++++++++++++++++ .../knotx/conf/knots/templateEngineKnot.conf | 31 ++++ .../knotx/conf/knots/templateEngineStack.conf | 11 ++ aem/gradle/environment/knotx/conf/logback.xml | 39 ++++ .../environment/knotx/conf/openapi.yaml | 32 ++++ .../routes/handlers/fragmentsHandler.conf | 34 ++++ .../handlers/httpRepoConnectorHandler.conf | 61 +++++++ .../knotx/conf/routes/operations.conf | 30 +++ aem/gradle/environment/knotx/conf/server.conf | 85 +++++++++ 13 files changed, 538 insertions(+) create mode 100644 aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf create mode 100644 aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory create mode 100644 aem/gradle/environment/knotx/conf/application.conf create mode 100644 aem/gradle/environment/knotx/conf/bootstrap.json create mode 100644 aem/gradle/environment/knotx/conf/default-cluster.xml create mode 100644 aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf create mode 100644 aem/gradle/environment/knotx/conf/knots/templateEngineStack.conf create mode 100644 aem/gradle/environment/knotx/conf/logback.xml create mode 100644 aem/gradle/environment/knotx/conf/openapi.yaml create mode 100644 aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf create mode 100644 aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf create mode 100644 aem/gradle/environment/knotx/conf/routes/operations.conf create mode 100644 aem/gradle/environment/knotx/conf/server.conf diff --git a/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf b/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf new file mode 100644 index 00000000..5b6dcd15 --- /dev/null +++ b/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf @@ -0,0 +1,7 @@ + + ServerName knotx.example.com + + ProxyPass "/" "http://knotx:8092/" + ProxyPassReverse "/" "http://knotx:8092/" + + diff --git a/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory b/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory new file mode 100644 index 00000000..d6aec979 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory @@ -0,0 +1,10 @@ +# FixMe - this was fixed after RC1 release and may be removed when RC2 is released + +# behaviours +io.knotx.fragments.handler.action.CircuitBreakerActionFactory +io.knotx.fragments.handler.action.InMemoryCacheActionFactory + +# pre-defined actions +io.knotx.fragments.handler.action.InlineBodyActionFactory +io.knotx.fragments.handler.action.InlinePayloadActionFactory +io.knotx.fragments.handler.action.KnotFactory \ No newline at end of file diff --git a/aem/gradle/environment/knotx/conf/application.conf b/aem/gradle/environment/knotx/conf/application.conf new file mode 100644 index 00000000..28bc3799 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/application.conf @@ -0,0 +1,12 @@ +########### Modules to start ########### +# Modules map specify a list of verticles to be started by Knot.x. +# Each line should have a form of = +# where alias is just a name that you can use later in order to define configuration for the module +# verticle-class-name is a fully qualified class name of the verticle. +# +# This JSON object is filled in included files. +modules {} + + +include required(classpath("server.conf")) +include required(classpath("knots/templateEngineStack.conf")) diff --git a/aem/gradle/environment/knotx/conf/bootstrap.json b/aem/gradle/environment/knotx/conf/bootstrap.json new file mode 100644 index 00000000..9610e6fb --- /dev/null +++ b/aem/gradle/environment/knotx/conf/bootstrap.json @@ -0,0 +1,15 @@ +{ + "configRetrieverOptions": { + "scanPeriod": 5000, + "stores": [ + { + "type": "file", + "format": "conf", + "config": { + "path": "${KNOTX_HOME}/conf/application.conf" + }, + "optional": false + } + ] + } +} diff --git a/aem/gradle/environment/knotx/conf/default-cluster.xml b/aem/gradle/environment/knotx/conf/default-cluster.xml new file mode 100644 index 00000000..eefb1e0b --- /dev/null +++ b/aem/gradle/environment/knotx/conf/default-cluster.xml @@ -0,0 +1,171 @@ + + + + + + false + false + false + 5 + + + + dev + dev-pass + + http://localhost:8080/mancenter + + 5701 + + + 0 + + + + 224.2.2.3 + 54327 + + + 192.168.1.28 + + + my-access-key + my-secret-key + + us-west-1 + + ec2.amazonaws.com + + hazelcast-sg + type + hz-nodes + + + + 10.10.1.* + + + + + + PBEWithMD5AndDES + + thesalt + + thepass + + 19 + + + + + 16 + + 0 + + + + + + 1 + + + + + + 1 + + 0 + + 0 + + NONE + + 0 + + 25 + + com.hazelcast.map.merge.LatestUpdateMapMergePolicy + + + + + + 1 + + + diff --git a/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf b/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf new file mode 100644 index 00000000..a6e713ee --- /dev/null +++ b/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf @@ -0,0 +1,31 @@ +# Vert.x event bus delivery options used when communicating with other verticles +# see http://vertx.io/docs/vertx-core/dataobjects.html#DeliveryOptions for the details what can be configured +# deliveryOptions {} + +# Sets the default engine that will be used when no template engine strategy is specified in the snippet +defaultEngine = handlebars + +engines = [ + { + name = handlebars + config = { + # Algorithm used to build a hash key of the compiled handlebars snippets. + # The hash is computed for the snippet handlebars source code using a selected algorithm. + # The name should be a standard Java Security name (such as "SHA", "MD5", and so on). + # Default value is MD5 + # + # cacheKeyAlgorithm = MD5 + + # Size of the compiled snippets cache. After reaching the max size, new elements will replace the oldest one. + cacheSize = 1000 + + # Symbol used as a start delimiter of handlebars expression. If not use, a default '{{' is used + # + # startDelimiter = + + # Symbol used as a end delimiter of handlebars expression. If not use, a default '}}' is used + # + # endDelimiter = + } + } +] diff --git a/aem/gradle/environment/knotx/conf/knots/templateEngineStack.conf b/aem/gradle/environment/knotx/conf/knots/templateEngineStack.conf new file mode 100644 index 00000000..2ad64f1c --- /dev/null +++ b/aem/gradle/environment/knotx/conf/knots/templateEngineStack.conf @@ -0,0 +1,11 @@ +########### Data Bridge Stack ########### +modules { + templateEngine = "io.knotx.te.core.TemplateEngineKnot" +} + +########### Modules configurations ########### +config.templateEngine { + options.config { + include required(classpath("knots/templateEngineKnot.conf")) + } +} diff --git a/aem/gradle/environment/knotx/conf/logback.xml b/aem/gradle/environment/knotx/conf/logback.xml new file mode 100644 index 00000000..f02905f3 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/logback.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n + + + + + + + + + + + + diff --git a/aem/gradle/environment/knotx/conf/openapi.yaml b/aem/gradle/environment/knotx/conf/openapi.yaml new file mode 100644 index 00000000..d77b51c4 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/openapi.yaml @@ -0,0 +1,32 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Knot.x Stack OAS + description: This is the server API specification. + +servers: +- url: https://{domain}:{port} + description: The local API server + variables: + domain: + default: localhost + description: api domain + port: + enum: + - '8092' + - '443' + default: '8092' + +paths: + /products/*: + get: + operationId: products-get + responses: + default: + description: Remote repository template processing with http action and te + /assets/*: + get: + operationId: assets-get + responses: + default: + description: Return assets as is from the repository diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf new file mode 100644 index 00000000..e06e9fb4 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf @@ -0,0 +1,34 @@ +########### This configuration is overloaded in integration tests! ########### +tasks { + hello-world { + action = hello-inline + onTransitions { + _success { + action = te + } + } + } +} + +actions { + hello-inline { + factory = inline-payload + config { + alias = hello + payload { + _result { + message = "Hello Knot.x with GAP" + } + } + } + } + te { + factory = "knot" + config { + address = "knotx.knot.te" + deliveryOptions { + sendTimeout = 3000 + } + } + } +} diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf new file mode 100644 index 00000000..8e0e8106 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf @@ -0,0 +1,61 @@ +# Vert.x event bus delivery options used when communicating with other verticles +# see http://vertx.io/docs/vertx-core/dataobjects.html#HttpClientOptions for the details what can be configured +# +clientOptions { + maxPoolSize = 1000 + idleTimeout = 120 # seconds + tryUseCompression = true + + # If you're going to use SSL (clientDestination.scheme='https') then here you'd need to configure + # some aspects related to the SSL negotiation and validation. + # + # Whether all server certificated should be trusted or not (e.g. self-signed certificates) + # trustAll = true + # + # Hostname verification + # verifyHost = false + # + # It will force SSL SNI (Server Name Indication). The SNI will be set to the same value as 'hostHeader' (set in ClientDestination) + # forceSni = true +} + +# HTTP Repository connection details +clientDestination { + # Connection scheme: http or https + scheme = http + + # domain or the IP of the host: e.g. localhost, 10.0.11.2 + domain = httpd + + ## Port on which the host listens, e.g. 8080, 3001, etc. + port = 80 + + # Host header override to be used with a communication to the repository. If it's set, it overrides any value in the 'Host' header, and sets the SNI SSL to the same value. + # hostHeader = +} + +# List of allowed request headers that will be send to HTTP repository. +# Each item is a string that defines regex, e.g. to match any char use `.*` +# +allowedRequestHeaders = [ + "Accept.*" + Authorization + Connection + Cookie + Date + "Edge.*" + "If.*" + Origin + Pragma + Proxy-Authorization + "Surrogate.*" + User-Agent + Via + "X-.*" +] + +# Statically defined HTTP request header sent in every request to the repository +customHttpHeader = { + name = X-User-Agent + value = Knot.x +} diff --git a/aem/gradle/environment/knotx/conf/routes/operations.conf b/aem/gradle/environment/knotx/conf/routes/operations.conf new file mode 100644 index 00000000..9421ca11 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/routes/operations.conf @@ -0,0 +1,30 @@ +routingOperations = ${routingOperations} [ + { + operationId = products-get + handlers = ${config.server.handlers.common.request} [ + { + name = httpRepoConnectorHandler + config = { include required(classpath("routes/handlers/httpRepoConnectorHandler.conf")) } + }, + { + name = splitterHandler + }, + { + name = fragmentsHandler + config = { include required(classpath("routes/handlers/fragmentsHandler.conf")) } + }, + { + name = assemblerHandler + } + ] ${config.server.handlers.common.response} + } + { + operationId = assets-get + handlers = ${config.server.handlers.common.request} [ + { + name = httpRepoConnectorHandler + config = { include required(classpath("routes/handlers/httpRepoConnectorHandler.conf")) } + } + ] ${config.server.handlers.common.response} + } +] diff --git a/aem/gradle/environment/knotx/conf/server.conf b/aem/gradle/environment/knotx/conf/server.conf new file mode 100644 index 00000000..b95716b8 --- /dev/null +++ b/aem/gradle/environment/knotx/conf/server.conf @@ -0,0 +1,85 @@ +########### Knot.x Server ########### +modules { + server = "io.knotx.server.KnotxServerVerticle" +} + +########### Modules configurations ########### +config.server { + handlers.common { + request = [ + { + name = cookieHandler + }, + { + name = bodyHandler + }, + { + name = requestContextHandler + } + ], + response = [ + { + name = headerHandler + # Statically defined HTTP response header returned to the client in every HTTP response + config { + name = X-Server + value = Knot.x-Custom-Header + } + }, + { + name = writerHandler + # List of HTTP response headers Knot.x can return to the client + config.allowedResponseHeaders = [ + Access-Control-Allow-Origin + Content-Type + Content-Length + ] + } + ] + } + options.config { + # Configuraiton of HTTP server + serverOptions { + # Knot.x server HTTP port + port = 8092 + + # If you want a server to serve SSL connections you can configure it here + # + # Enable SSL + # ssl = true + # + # Path on the server the keystore.jks file is located + # keyStoreOptions.path = + # + # Keystore password + # keyStoreOptions.password = + } + + # Location of your Open API spec. It can be an absolute path, a local path or remote url (with HTTP protocol). + routingSpecificationLocation = /openapi.yaml + + displayExceptionDetails = true + dropRequestOptions { + # FixMe this should be enabled by default, see https://github.com/Knotx/knotx-server-http/issues/20 for details + enabled = false + + # Status code that is served if the response is dropped, default is 429, "Too Many Requests" + # dropRequestResponseCode = + + # Number of request that single Server insance can support concurrently. Default value is 1000. + # backpressureBufferCapacity + + # Strategy how to deal with backpressure buffer overflow. Default is DROP_LATEST. + # backpressureStrategy = + } + + routingOperations = [] + include required(classpath("routes/operations.conf")) + } + + # The options object carries-on configuration called DeploymentOptions for a given verticle. + # It allows you to control the verticle behaviour, such as how many instances, classpath isolation, workers, etc. + # See available options http://vertx.io/docs/vertx-core/dataobjects.html#DeploymentOptions + # + # options {} +} From f597792ee5563c191e81a47f6e59f90e8aeb4d89 Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Wed, 15 May 2019 12:41:50 +0200 Subject: [PATCH 02/11] ugly aem page with knotx snippet #61 --- aem/gradle/environment/knotx/conf/logback.xml | 3 +- .../handlers/httpRepoConnectorHandler.conf | 1 + .../example/demo/products/.content.xml | 16 +++++++ .../demo/products/details/.content.xml | 13 ++++++ .../products-detail-page/.content.xml | 7 +++ .../products-detail-page.html | 43 +++++++++++++++++++ .../products-detail-page/.content.xml | 13 ++++++ .../aem/sites/components/page/PageModel.kt | 7 +-- 8 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 aem/site.demo/src/main/content/jcr_root/content/example/demo/products/.content.xml create mode 100644 aem/site.demo/src/main/content/jcr_root/content/example/demo/products/details/.content.xml create mode 100644 aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/.content.xml create mode 100644 aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/products-detail-page.html create mode 100644 aem/sites/src/main/content/jcr_root/apps/example/sites/templates/products-detail-page/.content.xml diff --git a/aem/gradle/environment/knotx/conf/logback.xml b/aem/gradle/environment/knotx/conf/logback.xml index f02905f3..001d85e6 100644 --- a/aem/gradle/environment/knotx/conf/logback.xml +++ b/aem/gradle/environment/knotx/conf/logback.xml @@ -33,7 +33,8 @@ + - + diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf index 8e0e8106..098786d5 100644 --- a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf +++ b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf @@ -52,6 +52,7 @@ allowedRequestHeaders = [ User-Agent Via "X-.*" + "Host.*" ] # Statically defined HTTP request header sent in every request to the repository diff --git a/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/.content.xml b/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/.content.xml new file mode 100644 index 00000000..cfb9f94a --- /dev/null +++ b/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/.content.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/details/.content.xml b/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/details/.content.xml new file mode 100644 index 00000000..02d758bd --- /dev/null +++ b/aem/site.demo/src/main/content/jcr_root/content/example/demo/products/details/.content.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/.content.xml b/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/.content.xml new file mode 100644 index 00000000..6b9d615e --- /dev/null +++ b/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/.content.xml @@ -0,0 +1,7 @@ + + diff --git a/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/products-detail-page.html b/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/products-detail-page.html new file mode 100644 index 00000000..5aabd9ef --- /dev/null +++ b/aem/sites/src/main/content/jcr_root/apps/example/sites/components/products-detail-page/products-detail-page.html @@ -0,0 +1,43 @@ + + + + + + Example | ${page.title} + + + + + + +
+ +

{{hello._result.message}}

+
+
+
+
+
+ AEM application built by +
+
+ + + +
+
+ +
+ All rights reserved | 2019 © Company +
+
+ + + + + diff --git a/aem/sites/src/main/content/jcr_root/apps/example/sites/templates/products-detail-page/.content.xml b/aem/sites/src/main/content/jcr_root/apps/example/sites/templates/products-detail-page/.content.xml new file mode 100644 index 00000000..eceb96e6 --- /dev/null +++ b/aem/sites/src/main/content/jcr_root/apps/example/sites/templates/products-detail-page/.content.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/aem/sites/src/main/kotlin/com/company/example/aem/sites/components/page/PageModel.kt b/aem/sites/src/main/kotlin/com/company/example/aem/sites/components/page/PageModel.kt index 9edcbed2..554bffe7 100644 --- a/aem/sites/src/main/kotlin/com/company/example/aem/sites/components/page/PageModel.kt +++ b/aem/sites/src/main/kotlin/com/company/example/aem/sites/components/page/PageModel.kt @@ -56,10 +56,11 @@ class PageModel : Serializable { } private fun determineLanguageCode(): String { - val languagePath = LanguageUtil.getLanguageRoot(resource.path) - val languagePart = languagePath.substringAfterLast("/") +// val languagePath = LanguageUtil.getLanguageRoot(resource.path) +// val languagePart = languagePath.substringAfterLast("/") - return LanguageUtil.getLanguage(languagePart).languageCode ?: "en" +// return LanguageUtil.getLanguage(languagePart).languageCode ?: "en" + return "en" } } From 7a6e7aec81e5d4bfa228ccc4ef66d82d17e9e061 Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Wed, 15 May 2019 14:32:07 +0200 Subject: [PATCH 03/11] fix log files on knotx container --- aem/gradle/environment/knotx/conf/logback.xml | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/aem/gradle/environment/knotx/conf/logback.xml b/aem/gradle/environment/knotx/conf/logback.xml index 001d85e6..5522764b 100644 --- a/aem/gradle/environment/knotx/conf/logback.xml +++ b/aem/gradle/environment/knotx/conf/logback.xml @@ -17,24 +17,25 @@ --> - - - - - - - - %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n - - - - - - - - - - - - + + + + + + + + + + %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n + + + + + + + + + + + From d8ec3421f63873507e30ea4fc061c76e95f16612 Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Wed, 22 May 2019 11:19:34 +0200 Subject: [PATCH 04/11] rebase with develop --- aem/gradle/environment.gradle.kts | 7 +++++-- aem/gradle/environment/docker-compose.yml.peb | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/aem/gradle/environment.gradle.kts b/aem/gradle/environment.gradle.kts index 24192a1e..9dcc1fbc 100644 --- a/aem/gradle/environment.gradle.kts +++ b/aem/gradle/environment.gradle.kts @@ -6,11 +6,13 @@ configure { "example.com", "demo.example.com", "author.example.com", - "invalidation-only" + "invalidation-only", + "knotx.example.com" ) directories { regular( - "httpd/logs" + "httpd/logs", + "knotx/logs" ) cache( "httpd/cache/content/example/live", @@ -22,6 +24,7 @@ configure { url("Demo site", "http://demo.example.com/en-us.html", text = "English") url("Author login", "http://author.example.com/libs/granite/core/content/login.html" + "?resource=%2F&\$\$login\$\$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown", text = "AEM Sign In") + url("Knot.x", "http://knotx.example.com/", statusCode = 404) } } diff --git a/aem/gradle/environment/docker-compose.yml.peb b/aem/gradle/environment/docker-compose.yml.peb index a0eee10a..cffc8b97 100644 --- a/aem/gradle/environment/docker-compose.yml.peb +++ b/aem/gradle/environment/docker-compose.yml.peb @@ -20,5 +20,15 @@ services: extra_hosts: - "host.docker.internal:10.0.2.2" {% endif %} + knotx: + image: knotx/knotx:2.0.0-RC1 + command: ["knotx", "run-knotx"] + volumes: + - "{{ environment.dockerConfigPath }}/knotx/conf:/usr/local/knotx/conf" + - "{{ environment.dockerRootPath }}/knotx/logs:/usr/local/knotx/logs" + ports: + - "8092:8092" + networks: + - docker-net networks: docker-net: From 6cb245b9078843b8cb044fa59554d9918dea8342 Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Wed, 22 May 2019 11:27:37 +0200 Subject: [PATCH 05/11] map knotx logs volume --- aem/gradle/environment/docker-compose.yml.peb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aem/gradle/environment/docker-compose.yml.peb b/aem/gradle/environment/docker-compose.yml.peb index cffc8b97..6e1f8c46 100644 --- a/aem/gradle/environment/docker-compose.yml.peb +++ b/aem/gradle/environment/docker-compose.yml.peb @@ -25,7 +25,7 @@ services: command: ["knotx", "run-knotx"] volumes: - "{{ environment.dockerConfigPath }}/knotx/conf:/usr/local/knotx/conf" - - "{{ environment.dockerRootPath }}/knotx/logs:/usr/local/knotx/logs" + - "{{ environment.dockerRootPath }}/knotx/logs:/var/log/knotx" ports: - "8092:8092" networks: From a12a0969dab6b9ee15eff7e2098d583f3f24ca0b Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Fri, 14 Jun 2019 09:14:00 +0200 Subject: [PATCH 06/11] knotx hosts config with trafic router --- aem/gradle/environment/httpd/conf/httpd.conf | 2 +- .../httpd/conf/vhost/knotx.example.com.conf | 11 +++++++++-- .../routes/handlers/httpRepoConnectorHandler.conf | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/aem/gradle/environment/httpd/conf/httpd.conf b/aem/gradle/environment/httpd/conf/httpd.conf index 20c91dce..1fc48101 100644 --- a/aem/gradle/environment/httpd/conf/httpd.conf +++ b/aem/gradle/environment/httpd/conf/httpd.conf @@ -194,7 +194,7 @@ LoadModule dir_module modules/mod_dir.so #LoadModule speling_module modules/mod_speling.so #LoadModule userdir_module modules/mod_userdir.so LoadModule alias_module modules/mod_alias.so -#LoadModule rewrite_module modules/mod_rewrite.so +LoadModule rewrite_module modules/mod_rewrite.so LoadModule dispatcher_module modules/mod_dispatcher.so diff --git a/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf b/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf index 5b6dcd15..6b5945c7 100644 --- a/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf +++ b/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf @@ -1,7 +1,14 @@ ServerName knotx.example.com - ProxyPass "/" "http://knotx:8092/" - ProxyPassReverse "/" "http://knotx:8092/" + RewriteEngine On + + RewriteCond %{REQUEST_METHOD} =GET + RewriteRule ^(.*\.html)$ - [E=KNOTX_REQ:true] + + RewriteCond %{ENV:KNOTX_REQ} ^true$ + RewriteRule ^/(.*)$ http://knotx:8092/$1 [P,L] + + RewriteRule ^/(.*)$ http://demo.example.com/$1 [P,L] diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf index 098786d5..f56546c5 100644 --- a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf +++ b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf @@ -25,7 +25,7 @@ clientDestination { scheme = http # domain or the IP of the host: e.g. localhost, 10.0.11.2 - domain = httpd + domain = demo.example.com ## Port on which the host listens, e.g. 8080, 3001, etc. port = 80 From 51d33670b9ede5d461fa9350ad4e7bcc1dea26df Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Wed, 3 Jul 2019 11:39:43 +0200 Subject: [PATCH 07/11] Update Knot.x configs to RC4. --- aem/gradle/environment/docker-compose.yml.peb | 2 +- ....knotx.fragments.handler.api.ActionFactory | 10 - .../knotx/conf/default-cluster.xml | 171 ------------------ .../knotx/conf/knots/templateEngineKnot.conf | 45 ++--- .../routes/handlers/fragmentsHandler.conf | 8 +- .../knotx/conf/routes/operations.conf | 4 +- aem/gradle/environment/knotx/conf/server.conf | 12 ++ 7 files changed, 39 insertions(+), 213 deletions(-) delete mode 100644 aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory delete mode 100644 aem/gradle/environment/knotx/conf/default-cluster.xml diff --git a/aem/gradle/environment/docker-compose.yml.peb b/aem/gradle/environment/docker-compose.yml.peb index 833c88b5..1bedaa34 100644 --- a/aem/gradle/environment/docker-compose.yml.peb +++ b/aem/gradle/environment/docker-compose.yml.peb @@ -21,7 +21,7 @@ services: - "host.docker.internal:10.0.2.2" {% endif %} knotx: - image: knotx/knotx:2.0.0-RC1 + image: knotx/knotx:2.0.0-RC4 command: ["knotx", "run-knotx"] volumes: - "{{ environment.dockerConfigPath }}/knotx/conf:/usr/local/knotx/conf" diff --git a/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory b/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory deleted file mode 100644 index d6aec979..00000000 --- a/aem/gradle/environment/knotx/conf/META-INF/services/io.knotx.fragments.handler.api.ActionFactory +++ /dev/null @@ -1,10 +0,0 @@ -# FixMe - this was fixed after RC1 release and may be removed when RC2 is released - -# behaviours -io.knotx.fragments.handler.action.CircuitBreakerActionFactory -io.knotx.fragments.handler.action.InMemoryCacheActionFactory - -# pre-defined actions -io.knotx.fragments.handler.action.InlineBodyActionFactory -io.knotx.fragments.handler.action.InlinePayloadActionFactory -io.knotx.fragments.handler.action.KnotFactory \ No newline at end of file diff --git a/aem/gradle/environment/knotx/conf/default-cluster.xml b/aem/gradle/environment/knotx/conf/default-cluster.xml deleted file mode 100644 index eefb1e0b..00000000 --- a/aem/gradle/environment/knotx/conf/default-cluster.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - false - false - false - 5 - - - - dev - dev-pass - - http://localhost:8080/mancenter - - 5701 - - - 0 - - - - 224.2.2.3 - 54327 - - - 192.168.1.28 - - - my-access-key - my-secret-key - - us-west-1 - - ec2.amazonaws.com - - hazelcast-sg - type - hz-nodes - - - - 10.10.1.* - - - - - - PBEWithMD5AndDES - - thesalt - - thepass - - 19 - - - - - 16 - - 0 - - - - - - 1 - - - - - - 1 - - 0 - - 0 - - NONE - - 0 - - 25 - - com.hazelcast.map.merge.LatestUpdateMapMergePolicy - - - - - - 1 - - - diff --git a/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf b/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf index a6e713ee..c8624e70 100644 --- a/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf +++ b/aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf @@ -1,31 +1,26 @@ # Vert.x event bus delivery options used when communicating with other verticles -# see http://vertx.io/docs/vertx-core/dataobjects.html#DeliveryOptions for the details what can be configured -# deliveryOptions {} +address = knotx.knot.te.handlebars -# Sets the default engine that will be used when no template engine strategy is specified in the snippet -defaultEngine = handlebars +engine { + factory = handlebars + config = { + # Algorithm used to build a hash key of the compiled handlebars snippets. + # The hash is computed for the snippet handlebars source code using a selected algorithm. + # The name should be a standard Java Security name (such as "SHA", "MD5", and so on). + # Default value is MD5 + # + # cacheKeyAlgorithm = MD5 -engines = [ - { - name = handlebars - config = { - # Algorithm used to build a hash key of the compiled handlebars snippets. - # The hash is computed for the snippet handlebars source code using a selected algorithm. - # The name should be a standard Java Security name (such as "SHA", "MD5", and so on). - # Default value is MD5 - # - # cacheKeyAlgorithm = MD5 + # Size of the compiled snippets cache. After reaching the max size, new elements will replace the oldest one. + cacheSize = 1000 - # Size of the compiled snippets cache. After reaching the max size, new elements will replace the oldest one. - cacheSize = 1000 + # Symbol used as a start delimiter of handlebars expression. If not use, a default '{{' is used + # + # startDelimiter = - # Symbol used as a start delimiter of handlebars expression. If not use, a default '{{' is used - # - # startDelimiter = - - # Symbol used as a end delimiter of handlebars expression. If not use, a default '}}' is used - # - # endDelimiter = - } + # Symbol used as a end delimiter of handlebars expression. If not use, a default '}}' is used + # + # endDelimiter = } -] +} + diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf index e06e9fb4..cf5056af 100644 --- a/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf +++ b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf @@ -4,7 +4,7 @@ tasks { action = hello-inline onTransitions { _success { - action = te + action = te-hbs } } } @@ -22,10 +22,10 @@ actions { } } } - te { - factory = "knot" + te-hbs { + factory = knot config { - address = "knotx.knot.te" + address = knotx.knot.te.handlebars deliveryOptions { sendTimeout = 3000 } diff --git a/aem/gradle/environment/knotx/conf/routes/operations.conf b/aem/gradle/environment/knotx/conf/routes/operations.conf index 9421ca11..061a27f4 100644 --- a/aem/gradle/environment/knotx/conf/routes/operations.conf +++ b/aem/gradle/environment/knotx/conf/routes/operations.conf @@ -7,14 +7,14 @@ routingOperations = ${routingOperations} [ config = { include required(classpath("routes/handlers/httpRepoConnectorHandler.conf")) } }, { - name = splitterHandler + name = fragmentsProviderHtmlSplitter }, { name = fragmentsHandler config = { include required(classpath("routes/handlers/fragmentsHandler.conf")) } }, { - name = assemblerHandler + name = fragmentsAssemblerHandler } ] ${config.server.handlers.common.response} } diff --git a/aem/gradle/environment/knotx/conf/server.conf b/aem/gradle/environment/knotx/conf/server.conf index b95716b8..ac69a109 100644 --- a/aem/gradle/environment/knotx/conf/server.conf +++ b/aem/gradle/environment/knotx/conf/server.conf @@ -75,6 +75,18 @@ config.server { routingOperations = [] include required(classpath("routes/operations.conf")) + + # Global handlers section + globalHandlers = [ + # access log, by default logged to the knotx-access.log in the logs directory + { + name = loggerHandler + config { + immediate = true + format = DEFAULT + } + } + ] } # The options object carries-on configuration called DeploymentOptions for a given verticle. From 1de63d206c84a5c3a33c45c74e95113b77796f99 Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Fri, 5 Jul 2019 15:26:00 +0200 Subject: [PATCH 08/11] Fixing invalid DNS resolution. Bump Knot.x version to RC5. --- aem/gradle/environment/docker-compose.yml.peb | 2 +- .../knotx/conf/routes/handlers/httpRepoConnectorHandler.conf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aem/gradle/environment/docker-compose.yml.peb b/aem/gradle/environment/docker-compose.yml.peb index 1bedaa34..14fcd714 100644 --- a/aem/gradle/environment/docker-compose.yml.peb +++ b/aem/gradle/environment/docker-compose.yml.peb @@ -21,7 +21,7 @@ services: - "host.docker.internal:10.0.2.2" {% endif %} knotx: - image: knotx/knotx:2.0.0-RC4 + image: knotx/knotx:2.0.0-RC5 command: ["knotx", "run-knotx"] volumes: - "{{ environment.dockerConfigPath }}/knotx/conf:/usr/local/knotx/conf" diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf index f56546c5..cf5472e1 100644 --- a/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf +++ b/aem/gradle/environment/knotx/conf/routes/handlers/httpRepoConnectorHandler.conf @@ -25,13 +25,13 @@ clientDestination { scheme = http # domain or the IP of the host: e.g. localhost, 10.0.11.2 - domain = demo.example.com + domain = httpd ## Port on which the host listens, e.g. 8080, 3001, etc. port = 80 # Host header override to be used with a communication to the repository. If it's set, it overrides any value in the 'Host' header, and sets the SNI SSL to the same value. - # hostHeader = + hostHeader = demo.example.com } # List of allowed request headers that will be send to HTTP repository. From 16bda85dcfd643ace6dcbb0273292b3ab4d13925 Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Fri, 5 Jul 2019 16:20:46 +0200 Subject: [PATCH 09/11] Healthcheck added --- aem/gradle/environment.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aem/gradle/environment.gradle.kts b/aem/gradle/environment.gradle.kts index 4d69c42a..c1bb7dea 100644 --- a/aem/gradle/environment.gradle.kts +++ b/aem/gradle/environment.gradle.kts @@ -29,7 +29,7 @@ configure { url("Demo site", "http://demo.example.com/en-us.html", text = "English") url("Author login", "http://author.example.com/libs/granite/core/content/login.html" + "?resource=%2F&\$\$login\$\$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown", text = "AEM Sign In") - url("Knot.x", "http://knotx.example.com/", statusCode = 404) + url("Knot.x", "http://knotx.example.com/products/details.html", text = "Hello Knot.x with GAP") } } From 209a064f2326805c5ab0994fa786de29d110f851 Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Sat, 6 Jul 2019 00:24:04 +0200 Subject: [PATCH 10/11] Updated README.md, changed domain to knotx.demo.ezample.com. --- README.md | 26 +++++++++++++++++-- aem/gradle/environment.gradle.kts | 4 +-- ...e.com.conf => knotx.demo.example.com.conf} | 2 +- .../routes/handlers/fragmentsHandler.conf | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) rename aem/gradle/environment/httpd/conf/vhost/{knotx.example.com.conf => knotx.demo.example.com.conf} (88%) diff --git a/README.md b/README.md index fa6fa178..d5d768dd 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,12 @@ Documentation for: ![Fork Props Dialog](docs/fork-props-dialog.png) -3. Setup local AEM instances with dependencies and AEM dispatcher (see [prerequisites](https://github.com/Cognifide/gradle-aem-plugin/tree/develop#environment-configuration)) then build application using command: +3. Setup the local DEV environment containing: +- AEM instances with dependencies +- AEM dispatcher (see [prerequisites](https://github.com/Cognifide/gradle-aem-plugin/tree/develop#environment-configuration)) +- [Knot.x](https://github.com/Knotx/knotx) (see [prerequisites](https://github.com/Cognifide/gradle-aem-plugin/tree/develop#environment-configuration)) + +and build AEM application using command: ```bash aem/hosts @@ -128,6 +133,7 @@ Project is configured to have local environment which consists of: * native AEM instances running on local file system, * virtualized Apache HTTP Server with AEM Dispatcher module running on Docker ([official httpd image](https://hub.docker.com/_/httpd)). +* virtualized [Knot.x](https://github.com/Knotx/knotx) reactive integration framework running on Docker Assumptions: @@ -137,6 +143,7 @@ Assumptions: * http://example.com -> which maps to `/content/example/live` content root on publish * http://demo.example.com -> which maps to `/content/example/demo` content root on publish * http://author.example.com -> which is proxy to the author instance + * http:://knotx.demo.example.com -> which maps to `/content/example/demo` content root on publish and [processes `` tags](https://github.com/Knotx/knotx-fragments) ## Building @@ -168,7 +175,7 @@ Task `setup` will: * set up AEM environment (run HTTPD service on Docker) and install AEM dispatcher module * build AEM application (compose assembly CRX package from many) * migrate AEM application (for projects already deployed on production to upgrade JCR content in case of changed application behavior) -* clean AEM environment (restart HTTPD service then clean AEM dispatcher caches) +* clean AEM environment (restart HTTPD service then clean AEM dispatcher caches, restart Knot.x) * check AEM environment (quickly check responsiveness of deployed application) * run integration tests * run functional tests @@ -176,6 +183,21 @@ Task `setup` will: To sum up, all things needed by developer are fully automated in one place / Gradle build. Still all separate concerns like running tests, only building application, only running tests, could be used separately by running particular Gradle tasks. +## Validation + +### AEM mappings +You can check AEM Dispatcher url rewrites with: + +[example.com/en-us.html](http://example.com/en-us.html) +[demo.example.com/en-us.html](http://demo.example.com/en-us.html) + +### Knot.x Fragments processing +Fully static template page containing "dynamic" placeholder from Dispatcher: +[demo.example.com/products/details.html](http://demo.example.com/products/details.html) + +Page containing data assembled by Knot.x: +[knotx.demo.example.com/products/details.html](http://knotx.demo.example.com/products/details.html) + ## Tips & tricks * To run some task only for subproject, use project path as a prefix, for instance: `gradlew :aem:site.demo:sync`. diff --git a/aem/gradle/environment.gradle.kts b/aem/gradle/environment.gradle.kts index c1bb7dea..0bc9d2b2 100644 --- a/aem/gradle/environment.gradle.kts +++ b/aem/gradle/environment.gradle.kts @@ -7,7 +7,7 @@ configure { "demo.example.com", "author.example.com", "dispatcher.example.com", - "knotx.example.com" + "knotx.demo.example.com" ) distributions { download("http://download.macromedia.com/dispatcher/download/dispatcher-apache2.4-linux-x86_64-4.3.2.tar.gz").then { @@ -29,7 +29,7 @@ configure { url("Demo site", "http://demo.example.com/en-us.html", text = "English") url("Author login", "http://author.example.com/libs/granite/core/content/login.html" + "?resource=%2F&\$\$login\$\$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown", text = "AEM Sign In") - url("Knot.x", "http://knotx.example.com/products/details.html", text = "Hello Knot.x with GAP") + url("Knot.x", "http://knotx.demo.example.com/products/details.html", text = "Content filled by Knot.x integration framework.") } } diff --git a/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf b/aem/gradle/environment/httpd/conf/vhost/knotx.demo.example.com.conf similarity index 88% rename from aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf rename to aem/gradle/environment/httpd/conf/vhost/knotx.demo.example.com.conf index 6b5945c7..ed8892f5 100644 --- a/aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf +++ b/aem/gradle/environment/httpd/conf/vhost/knotx.demo.example.com.conf @@ -1,5 +1,5 @@ - ServerName knotx.example.com + ServerName knotx.demo.example.com RewriteEngine On diff --git a/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf index cf5056af..a5df82cc 100644 --- a/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf +++ b/aem/gradle/environment/knotx/conf/routes/handlers/fragmentsHandler.conf @@ -17,7 +17,7 @@ actions { alias = hello payload { _result { - message = "Hello Knot.x with GAP" + message = "Content filled by Knot.x integration framework." } } } From d2a8267d80a779a71ba19c59cccb3bffc1261338 Mon Sep 17 00:00:00 2001 From: Tomasz Michalak Date: Mon, 22 Jul 2019 09:15:29 +0200 Subject: [PATCH 11/11] Update travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0a8e7c43..ee81afd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: java install: ./gradlew -i -S assemble -script: ./gradlew -i -S check +script: ./gradlew -i -S -Poffline=true check before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/