You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2020/07/30 18:08:49 UTC

[sling-org-apache-sling-app-cms] 02/02: Building the Composite NodeStore on build of the docker image

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch SLING-8913-multiple-instance-types
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit c49bc51632fd9b650199d30194f448b74bc808bf
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 30 14:07:39 2020 -0400

    Building the Composite NodeStore on build of the docker image
---
 docker/README.md                                   | 12 +++++-
 docker/cms/Dockerfile                              | 25 +++++++++---
 docker/cms/download-dependencies.sh                | 34 ++++++++++++++++
 docker/cms/settings.xml                            | 35 ++++++++++++++++
 docker/cms/setup-composite.sh                      | 47 ++++++++++++++++++++++
 docker/docker-compose.yml                          | 16 +++-----
 docker/webcache/Dockerfile                         | 10 ++---
 feature/pom.xml                                    | 16 ++++++--
 .../node-store-composite/composite-runtime.json    |  8 ++++
 .../node-store-composite/composite-seed.json       | 18 ++++++++-
 .../main/features/node-store-segment/segment.json  | 12 +++++-
 feature/src/main/features/sling_sling.json         |  8 ----
 12 files changed, 200 insertions(+), 41 deletions(-)

diff --git a/docker/README.md b/docker/README.md
index 538d23e..6d309cc 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -2,7 +2,7 @@
 
 This is a sample Docker Compose configuration for using Apache Sling CMS in a containerized environment.
 
-It will start a container with the Apache Sling CMS backed by MongoDB and a webcache container pre-configured to proxy and cache two URLs.
+It will start a container with the Apache Sling CMS backed by a shared volume and a webcache container pre-configured to proxy and cache two URLs.
 
 ## Dependencies
 
@@ -17,6 +17,16 @@ To build, run the command:
 
 `docker-compose build`
 
+If you are using snapshots, to force a rebuild, run:
+
+`docker-compose build --no-cache --force-rm`
+
+## Volume
+
+This Docker Compose setup creates a volume _docker_sling-repository_ for the Apache Sling CMS repository. To destroy this volume call:
+
+`docker rm docker_sling-repository`
+
 ## Use
 
 To use the containers, run the command:
diff --git a/docker/cms/Dockerfile b/docker/cms/Dockerfile
index 52692a4..2c56193 100644
--- a/docker/cms/Dockerfile
+++ b/docker/cms/Dockerfile
@@ -13,18 +13,31 @@
 
 # Pull base image.
 FROM adoptopenjdk:11-jre-openj9
-MAINTAINER dev@sling.apache.org
+
+ARG FM_GROUP_ID=org.apache.sling
+ARG FM_ARTIFACT_ID=org.apache.sling.cms.feature
+ARG FM_VERSION=0.16.3-SNAPSHOT
+ARG FM_SEED_CLASSIFIER=slingcms-composite-seed
+ARG FM_RUNTIME_CLASSIFIER=slingcms-composite-seed
+ENV FM_ARTIFACT_ID=${FM_ARTIFACT_ID}
+ENV FM_RUNTIME_CLASSIFIER=${FM_RUNTIME_CLASSIFIER}
 
 # Configure directories
-WORKDIR /opt/sling
-VOLUME /opt/sling/sling
+WORKDIR /opt/slingcms
+
+# Install Apache Maven
+RUN apt-get update && apt-get install maven -y
+COPY /settings.xml /root/.m2/
 
 # Setup Sling CMS
-RUN mkdir -p /opt/sling
-RUN curl -L https://search.maven.org/remotecontent?filepath=org/apache/sling/org.apache.sling.cms.builder/0.16.2/org.apache.sling.cms.builder-0.16.2.jar --output org.apache.sling.cms.jar
+COPY download-dependencies.sh /opt/slingcms/setup/
+RUN /bin/bash /opt/slingcms/setup/download-dependencies.sh
+COPY setup-composite.sh /opt/slingcms/setup/
+RUN /bin/bash /opt/slingcms/setup/setup-composite.sh
 
 # Expose endpoints
 EXPOSE 8080
 
 # Start Sling CMS
-CMD exec java -Dsling.run.modes=oak_mongo -Doak.mongo.uri=mongodb://mongo:27017 -Doak.mongo.db=sling -jar org.apache.sling.cms.jar
+CMD exec java -jar org.apache.sling.feature.launcher.jar \
+    -f ${FM_ARTIFACT_ID}-${FM_RUNTIME_CLASSIFIER}.slingosgifeature
diff --git a/docker/cms/download-dependencies.sh b/docker/cms/download-dependencies.sh
new file mode 100644
index 0000000..9705148
--- /dev/null
+++ b/docker/cms/download-dependencies.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+#		 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.
+#
+
+mkdir -p /opt/slingcms
+cd /opt/slingcms
+
+echo "Downloading Feature Launcher..."
+mvn -q org.apache.maven.plugins:maven-dependency-plugin:copy \
+    -Dartifact=org.apache.sling:org.apache.sling.feature.launcher:1.1.4:jar \
+    -DoutputDirectory=/opt/slingcms \
+    -Dmdep.stripVersion=true \
+    || { echo 'Failed to download Feature Launcher' ; exit 1; }
+ 
+echo "Downloading Feature Models..."
+mvn -q org.apache.maven.plugins:maven-dependency-plugin:copy \
+    -Dartifact=${FM_GROUP_ID}:${FM_ARTIFACT_ID}:${FM_VERSION}:slingosgifeature:${FM_SEED_CLASSIFIER} \
+    -DoutputDirectory=/opt/slingcms/setup \
+    -Dmdep.stripVersion=true \
+    || { echo 'Failed to download composite seed' ; exit 1; }
+mvn -q org.apache.maven.plugins:maven-dependency-plugin:copy \
+    -Dartifact=${FM_GROUP_ID}:${FM_ARTIFACT_ID}:${FM_VERSION}:slingosgifeature:${FM_RUNTIME_CLASSIFIER} \
+    -DoutputDirectory=/opt/slingcms \
+    -Dmdep.stripVersion=true \
+    || { echo 'Failed to download composite runtime' ; exit 1; }
\ No newline at end of file
diff --git a/docker/cms/settings.xml b/docker/cms/settings.xml
new file mode 100644
index 0000000..9abe7da
--- /dev/null
+++ b/docker/cms/settings.xml
@@ -0,0 +1,35 @@
+<!--
+    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.
+-->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
+                    https://maven.apache.org/xsd/settings-1.0.0.xsd">
+    <profiles>
+        <profile>
+            <id>apache-snapshots</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <repositories>
+                <repository>
+                    <id>apache.snapshots</id>
+                    <name>Apache Development Snapshot Repository</name>
+                    <url>https://repository.apache.org/content/repositories/snapshots/</url>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </repository>
+            </repositories>
+        </profile>
+    </profiles>
+</settings>
\ No newline at end of file
diff --git a/docker/cms/setup-composite.sh b/docker/cms/setup-composite.sh
new file mode 100644
index 0000000..0756d92
--- /dev/null
+++ b/docker/cms/setup-composite.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+#		 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.
+#
+
+SLING_USERNAME="${SLING_USERNAME:-admin}"
+SLING_PASSWORD="${SLING_PASSWORD:-admin}"
+
+echo "Creating composite seed..."
+java -jar org.apache.sling.feature.launcher.jar \
+    -f /opt/slingcms/setup/${FM_ARTIFACT_ID}-${FM_SEED_CLASSIFIER}.slingosgifeature &
+SLING_PID=$!
+echo "Sling PID: ${SLING_PID}"
+
+sleep 10s
+STARTED=1
+for i in {1..10}; do
+    echo "Checking to see if started with username: ${SLING_USERNAME}..."
+    STATUS=$(curl -4 -s -o /dev/null -w "%{http_code}" -u${SLING_USERNAME}:${SLING_PASSWORD} "http://localhost:8080/system/health.txt?tags=systemalive")
+    echo "Retrieved status: ${STATUS}"
+    if [ $STATUS -eq 200 ]; then
+        STARTED=0
+        break
+    fi
+    sleep 30s
+done
+
+if [ $STARTED -eq 1 ]; then
+    echo "Failed to seed sling repository!"
+    exit 2
+else
+    echo "Cleaning up seeding..."
+    rm -rf /opt/slingcms/launcher
+    cd sling/composite/repository-libs
+    ln -s segmentstore segmentstore-composite-mount-libs
+    cd ../../..
+    rm -rf /opt/slingcms/setup
+fi
+echo "Repository seeded successfully!"
\ No newline at end of file
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 01ec3ad..27856bb 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -9,23 +9,17 @@
 #  either express or implied. See the License for the specific language governing permissions
 #  and limitations under the License.
 #
-version: '3'
+version: '3.4'
 services:
   cms:
     build: cms
-    expose:
-      - "8080"
-    depends_on:
-    - mongo
-  mongo:
-    image: mongo
-    expose:
-    - "27017"
+    ports:
+      - "8080:8080"
     volumes:
-    - data-volume:/data/db
+      - sling-repository:/opt/slingcms/sling/composite/repository-global
   webcache:
     build: webcache
     ports:
       - "80:80"
 volumes:
-  data-volume:
+  sling-repository:
diff --git a/docker/webcache/Dockerfile b/docker/webcache/Dockerfile
index e9f2cdb..3e2c37d 100644
--- a/docker/webcache/Dockerfile
+++ b/docker/webcache/Dockerfile
@@ -13,14 +13,12 @@
 
 # Pull base image.
 FROM ubuntu:latest
-MAINTAINER dev@sling.apache.org
 
 # Avoid interaction with tzdata
 ARG DEBIAN_FRONTEND=noninteractive
 
 # Install Apache
-RUN apt-get update
-RUN apt-get install apache2 -y
+RUN apt-get update && apt-get install apache2 -y
 
 # Configure mod_rewrite
 RUN a2enmod rewrite
@@ -36,10 +34,8 @@ RUN a2enmod expires
 RUN a2enmod headers
 
 # Configure sites
-RUN mkdir -p /var/www/vhosts/sling-cms
-RUN mkdir -p /var/www/vhosts/sling
-COPY cms.conf /etc/apache2/sites-enabled
-COPY site.conf /etc/apache2/sites-enabled
+RUN mkdir -p /var/www/vhosts/sling-cms && mkdir -p /var/www/vhosts/sling
+COPY *.conf /etc/apache2/sites-enabled/
 
 # Expose endpoints
 EXPOSE 80
diff --git a/feature/pom.xml b/feature/pom.xml
index 59af970..5f71fc2 100644
--- a/feature/pom.xml
+++ b/feature/pom.xml
@@ -76,25 +76,33 @@
                         <aggregate>
                             <classifier>slingcms-segment</classifier>
                             <filesInclude>**/*.json</filesInclude>
-                            <filesExclude>node-store-composite/*.json</filesExclude>
+                            <filesExclude>node-store-composite/composite-*.json</filesExclude>
                             <title>Sling CMS -</title>
                         </aggregate>
                         <aggregate>
                             <classifier>slingcms-composite-seed</classifier>
                             <filesInclude>**/*.json</filesInclude>
-                            <filesExclude>node-store-composite/composite-runtime.json,node-store-segment/*.json</filesExclude>
+                            <filesExclude>node-store-composite/composite-runtime.json</filesExclude>
+                            <filesExclude>node-store-segment/segment.json</filesExclude>
                             <title>Sling CMS - Composite Node Store Seed</title>
                         </aggregate>
                         <aggregate>
                             <classifier>slingcms-composite-runtime</classifier>
                             <filesInclude>**/*.json</filesInclude>
-                            <filesExclude>node-store-composite/composite-seed.json,node-store-segment/*.json</filesExclude>
+                            <filesExclude>node-store-composite/composite-seed.json</filesExclude>
+                            <filesExclude>node-store-segment/segment.json</filesExclude>
                             <title>Sling CMS - Composite Node Store Runtime</title>
                         </aggregate>
                     </aggregates>
                     <scans>
                         <scan>
-                            <includeClassifier>slingcms-segment,slingcms-composite-seed,slingcms-composite-runtime</includeClassifier>
+                            <includeClassifier>slingcms-composite-runtime</includeClassifier>
+                        </scan>
+                        <scan>
+                            <includeClassifier>slingcms-composite-seed</includeClassifier>
+                        </scan>
+                        <scan>
+                            <includeClassifier>slingcms-segment</includeClassifier>
                         </scan>
                     </scans>
                     <archives>
diff --git a/feature/src/main/features/node-store-composite/composite-runtime.json b/feature/src/main/features/node-store-composite/composite-runtime.json
index b30683e..5f11296 100644
--- a/feature/src/main/features/node-store-composite/composite-runtime.json
+++ b/feature/src/main/features/node-store-composite/composite-runtime.json
@@ -49,6 +49,14 @@
             "registerDescriptors": true,
             "dispatchChanges": true,
             "repository.home": "sling/composite/repository-global"
+        },
+        "org.apache.sling.commons.log.LogManager": {
+            "org.apache.sling.commons.log.packagingDataEnabled": true,
+            "org.apache.sling.commons.log.pattern": "%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n",
+            "org.apache.sling.commons.log.level": "info",
+            "org.apache.sling.commons.log.file": "",
+            "org.apache.sling.commons.log.file.number:Integer": "-1",
+            "org.apache.sling.commons.log.file.size": ""
         }
     }
 }
\ No newline at end of file
diff --git a/feature/src/main/features/node-store-composite/composite-seed.json b/feature/src/main/features/node-store-composite/composite-seed.json
index 914d66f..ad29a0f 100644
--- a/feature/src/main/features/node-store-composite/composite-seed.json
+++ b/feature/src/main/features/node-store-composite/composite-seed.json
@@ -1,6 +1,9 @@
 {
     "id": "org.apache.sling:org.apache.sling.cms.feature:slingfeature:composite-seed:${cms.version}",
     "configurations": {
+        "org.apache.felix.hc.core.impl.servlet.HealthCheckExecutorServlet~default": {
+            "servletPath": "/system/health"
+        },
         "org.apache.jackrabbit.oak.segment.SegmentNodeStoreService": {
             "name": "Default NodeStore",
             "standby": true
@@ -15,11 +18,22 @@
         "org.apache.jackrabbit.oak.composite.MountInfoProviderService": {
             "mountName": "libs",
             "readOnlyMount": false,
-            "pathsSupportingFragments": [],
+            "pathsSupportingFragments": [
+                "/oak:index/*$"
+            ],
             "mountedPaths": [
                 "/libs",
-                "/apps"
+                "/apps",
+                "/jcr:system/rep:permissionStore/oak:mount-libs-default"
             ]
+        },
+        "org.apache.sling.commons.log.LogManager": {
+            "org.apache.sling.commons.log.packagingDataEnabled": true,
+            "org.apache.sling.commons.log.pattern": "%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n",
+            "org.apache.sling.commons.log.level": "info",
+            "org.apache.sling.commons.log.file": "",
+            "org.apache.sling.commons.log.file.number:Integer": "-1",
+            "org.apache.sling.commons.log.file.size": ""
         }
     }
 }
\ No newline at end of file
diff --git a/feature/src/main/features/node-store-segment/segment.json b/feature/src/main/features/node-store-segment/segment.json
index abcc4d4..5d16577 100644
--- a/feature/src/main/features/node-store-segment/segment.json
+++ b/feature/src/main/features/node-store-segment/segment.json
@@ -1,8 +1,16 @@
 {
     "id": "org.apache.sling:org.apache.sling.cms.feature:slingfeature:segment:${cms.version}",
     "configurations": {
-        "org.apache.jackrabbit.oak.segment.SegmentNodeStoreService":{
-            "name":"Default NodeStore"
+        "org.apache.jackrabbit.oak.segment.SegmentNodeStoreService": {
+            "name": "Default NodeStore"
+        },
+        "org.apache.sling.commons.log.LogManager": {
+            "org.apache.sling.commons.log.packagingDataEnabled": true,
+            "org.apache.sling.commons.log.pattern": "%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n",
+            "org.apache.sling.commons.log.level": "info",
+            "org.apache.sling.commons.log.file": "logs/error.log",
+            "org.apache.sling.commons.log.file.number:Integer": "7",
+            "org.apache.sling.commons.log.file.size": "'.'yyyy-MM-dd"
         }
     }
 }
\ No newline at end of file
diff --git a/feature/src/main/features/sling_sling.json b/feature/src/main/features/sling_sling.json
index 9c2a3d8..2d2f1e3 100644
--- a/feature/src/main/features/sling_sling.json
+++ b/feature/src/main/features/sling_sling.json
@@ -336,14 +336,6 @@
         }
     ],
     "configurations":{
-        "org.apache.sling.commons.log.LogManager":{
-            "org.apache.sling.commons.log.packagingDataEnabled":true,
-            "org.apache.sling.commons.log.pattern":"%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %msg%n",
-            "org.apache.sling.commons.log.level":"info",
-            "org.apache.sling.commons.log.file":"logs/error.log",
-            "org.apache.sling.commons.log.file.number:Integer":"7",
-            "org.apache.sling.commons.log.file.size":"'.'yyyy-MM-dd"
-        },
         "org.apache.sling.engine.impl.log.RequestLogger":{
             "access.log.enabled":true,
             "request.log.outputtype:Integer":"0",