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

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c84b0b  SLING-13208 - Allow including additional features when 
launching the Sling Starter container image (#627)
9c84b0b is described below

commit 9c84b0b2436264f91e865b56d788be3f2ac56b33
Author: Robert Munteanu <[email protected]>
AuthorDate: Wed May 20 16:18:10 2026 +0200

    SLING-13208 - Allow including additional features when launching the Sling 
Starter container image (#627)
    
    Introduce and document the --repository-urls and --extra-features flags
---
 README.md                        | 26 ++++++++++++
 src/main/container/bin/launch.sh | 87 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 108 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index cfac328..e4a7776 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,19 @@ following environment variables:
 | `JAVA_DEBUG_PORT`    | Run Sling Starter in Java debug mode   | `5005`       
        |
 | `EXTRA_JAVA_OPTS`    | Extra java options e.g `Xmx` or `Xms`. | `-Xms256m 
-Xmx2048m` |
 
+The following command arguments are supported:
+
+| Command argument | Description                            | Example          
    |
+|------------------|----------------------------------------|----------------------|
+| --repository-urls | Repository URLs to be used by Sling Starter. Replaces 
built-in values. | `file:///opt/sling/m2repo 
https://repo.maven.apache.org/maven2` |
+| --extra-features | Extra features to be added to the Sling Starter | 
`mvn:org.apache.sling/org.apache.sling.thumbnails/1.0.2/slingosgifeature/default`
 |
+
+
+> [!NOTE]  
+> The --extra-features argument is intended for quick experiments and 
debugging. When using the this functionality there is no guarantee that the 
features are compatible with the 
+> Sling Starter configuration and startup will proceed even if some bundles 
cannot resolve. It is recommended to build a custom image with the required 
features and to 
+> run the appropriate feature model analysers during the build.
+
 > **Example**
 > running Sling Starter in debug mode with custom memory settings
 
@@ -109,6 +122,19 @@ following environment variables:
 docker run -p 8080:8080 -p 5005:5005 -e JAVA_DEBUG_PORT=5005 -e 
EXTRA_JAVA_OPTS='-Xms256m -Xmx2048m' apache/sling:snapshot
 ```
 
+> running Sling Starter with an additional feature available in the default 
repositories
+
+```bash
+docker run -p 8080:8080 apache/sling:snapshot oak_tar --extra-features 
mvn:org.apache.sling/org.apache.sling.thumbnails/1.0.2/slingosgifeature/default
+```
+
+> running Sling Starter with a SNAPSHOT feature available in the local Maven 
repository
+
+```bash
+docker run -p 8080:8080 -v $HOME/.m2/repository:/opt/sling/m2repo 
apache/sling:snapshot oak_tar --repository-urls file:///opt/sling/m2repo 
https://repo.maven.apache.org/maven2  --extra-features 
mvn:org.apache.sling/org.apache.sling.thumbnails/1.0.3-SNAPSHOT/slingosgifeature/default
+```
+
+
 ## Building the Docker image
 
 This module can optionally build a Docker image. This is achieved by running a 
build with the `-Ddocker.skip=false` argument. By default, the image is built 
as `apache/sling:snapshot`. The tag can be overrriden using the 
`docker.image.tag` Maven property.
diff --git a/src/main/container/bin/launch.sh b/src/main/container/bin/launch.sh
index 002c7b2..e0f66ab 100755
--- a/src/main/container/bin/launch.sh
+++ b/src/main/container/bin/launch.sh
@@ -19,6 +19,54 @@
 
 
 feature_name="${1}"
+
+if [[ -z "${feature_name}" ]]; then
+    echo "[ERROR] Missing feature name. Aborting"
+    exit 1
+fi
+
+shift
+
+extra_features=()
+repository_urls=()
+
+while [[ $# -gt 0 ]]; do
+    case "$1" in
+        --extra-features)
+            shift
+            start_count=${#extra_features[@]}
+            while [[ $# -gt 0 && "$1" != -* ]]; do
+                extra_features+=("$1")
+                shift
+            done
+            if [[ ${#extra_features[@]} -eq ${start_count} ]]; then
+                echo "[ERROR] --extra-features requires at least one value. 
Aborting"
+                exit 1
+            fi
+            ;;
+        --repository-urls)
+            shift
+            start_count=${#repository_urls[@]}
+            while [[ $# -gt 0 && "$1" != -* ]]; do
+                repository_urls+=("$1")
+                shift
+            done
+            if [[ ${#repository_urls[@]} -eq ${start_count} ]]; then
+                echo "[ERROR] --repository-urls requires at least one value. 
Aborting"
+                exit 1
+            fi
+            ;;
+        -*)
+            echo "[ERROR] Unknown option $1. Aborting"
+            exit 1
+            ;;
+        *)
+            echo "[ERROR] Unexpected argument $1. Aborting"
+            exit 1
+            ;;
+    esac
+done
+
 feature=$(find artifacts -name "*${feature_name}*.slingosgifeature")
 
 if [[ ! -f "${feature}" ]]; then
@@ -31,7 +79,37 @@ docker_feature=$(find artifacts -name 
"*docker.slingosgifeature")
 echo "[INFO] Selected ${feature} for launching"
 echo "[INFO] Automatically appended ${docker_feature}"
 
-feature="${feature},${docker_feature}"
+feature_list=("${feature}")
+for extra_feature in "${extra_features[@]}"; do
+    echo "[INFO] Appended extra feature ${extra_feature}"
+    feature_list+=("${extra_feature}")
+done
+feature_list+=("${docker_feature}")
+
+feature=$(IFS=, ; printf '%s' "${feature_list[*]}")
+
+effective_repository_urls=(
+    "file:///opt/sling/artifacts"
+)
+
+if [[ ${#repository_urls[@]} -eq 0 ]]; then
+    effective_repository_urls+=(
+        "https://repo.maven.apache.org/maven2";
+        "https://repository.apache.org/content/groups/snapshots";
+    )
+else
+    effective_repository_urls+=("${repository_urls[@]}")
+fi
+
+launcher_args=(
+    -u
+    "${effective_repository_urls[@]}"
+    -CC "org.apache.sling.commons.log.LogManager=MERGE_LATEST"
+)
+
+echo "[INFO] Using repository URLs ${effective_repository_urls[*]}"
+
+launcher_args+=(-f "${feature}")
 
 if [ ! -z "${JAVA_DEBUG_PORT}" ]; then
     
JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:${JAVA_DEBUG_PORT}"
@@ -48,7 +126,6 @@ done
 export JAVA_OPTS
 echo "[INFO] JAVA_OPTS=${JAVA_OPTS}"
 
-exec org.apache.sling.feature.launcher/bin/launcher \
-    -c artifacts \
-    -CC "org.apache.sling.commons.log.LogManager=MERGE_LATEST" \
-    -f ${feature}
+echo "[INFO] Launch feature list: ${feature}"
+
+exec org.apache.sling.feature.launcher/bin/launcher "${launcher_args[@]}"

Reply via email to