Excerpt |
---|
STATUS: Proposal accepted |
Table of Contents | ||||
---|---|---|---|---|
|
Problem description
With the launchpad and provisioning model Sling Starter (or Launchpad) we always had a single deliverable - the executable jar. With the feature model this becomes more complicated, as we have multiple options for delivery and launch. We should make clear recommendations to our users, consumers of the Sling Starter, on how to obtain and launch it.
...
No Format |
---|
$ docker run -e MONGODB_HOST=mongo apache/sling:12 oak_mongo $ podman run -p 8080 apache/sling:12 oak_tar |
JBang
JBang allows for running Java "scripts" which are real Java classes executed with a real JVM, without having to preinstall anything other than JBang.
Comments-based annotations in the scripts can be used to declare dependencies that are automatically downloaded, select a specific JVM etc.
Installing JBang is easy and does not require a JVM to be pre-installed. If one is available it will be used but that's not a requirement, and other JVM versions can be downloaded as needed.
Here are a few examples of how it could be used for the Sling starter.
These all use a JBang catalog from the sling-whiteboard
repository, if we choose this option for the Sling Starter and other things we might create a specific sling-scripts
repository for the catalogs and scripts.
To bypass the local JBang cache in case changes are made to the catalog or scripts, use the --fresh
option.
Stub Sling Starter Script
The start.java script simulates starting Sling.
Thanks to the jbang-catalog.json file added to the Sling Whiteboard repository it can be called as follows, based on the JBang naming conventions for catalogs:
No Format |
---|
$ jbang start@apache/sling-whiteboard -p 1234
This is just a stub for now but could start Apache Sling with the following arguments: [-p, 1234] |
Parse a Repoinit Script
The RepoinitValidator.java script uses a //DEPS
comment to load the repoinit parser as a dependency. It is also listed in the Sling Whiteboard JBang catalog so can be called as follows:
No Format |
---|
$ echo "create path /itworks" | jbang repoinitValidator@apache/sling-whiteboard
Repoinit parsing successful:
[CreatePath [itworks]] |
Select a specific JVM version
The jvmVersion.java script uses a // JAVA comment to select a specific JVM version. It is also listed in the Sling Whiteboard JBang catalog so can be called as follows. Note that this downloads a JVM 13+ (and warns about that) if it's not available locally.
No Format |
---|
jbang jvmVersion@apache/sling-whiteboard
java.version=13.0.2 |
Evaluation
All the listed solutions fulfill the supported scenarios. To select a preferred solution, we should evaluate how easy they are to launch for our users.
Solution | Launch requirements | Launch complexity |
---|---|---|
Feature Launcher | Supported version of Java, Feature Launcher downloaded locally | Low-level, feature launcher flags |
Kickstart Launcher | Supported version of Java, Kickstart Launcher downloaded locally | High-level, kickstart launcher flags |
Feature Launcher Container | Container runtime engine | Low-level, feature launcher flags |
Sling Starter Container | Container runtime engine | High-level, Sling Starter env vars and flags |
JBang |
Proposal
Just JBang | Easy: simple command line with optional flags. Glue scripts do the rest. |
Java vs Containers
The assumption that a container engine is a lower execution bar compared to a Java Runtime for our users need to be qualified.
The Sling Starter supports a range of Java versions, e.g. 8-17. We don't only ask our users to have a Java Runtime installed, we ask them to have a specific version. Each new Java version potentially breaks the Sling Starter in a way, and historically we have not released the Sling Starter frequently enough to
It is a reasonable assumption that users are more likely to have recent versions of Java installed, rather than old ones. So the problem here would be that we are asking users to install older Java runtime versions, which a) they may not want to do and b) reflects poorly on us.
As for the availability of container engines, there are two data points available:
- In the JRebel Java developer productivity report 2021 Virtualisation category, 57% of respondents use Docker, 42% Kubernetes (multiple selections possible). Only 4% do not use a virtualisation tool
- The StackOverflow developer survey 2021 reports that 55% of professional developers have done extensive development work with Docker. Additionally, Docker is on the second spot in the most loved/wanted technologies, behind Git.
Proposal
Provide two recommended ways to launch the Sling Starter: the Sling Starter container, and a JBang catalog. Both of them will be presented together whenever one is documented. Make the Sling Starter Container the recommended way of launching the Sling Starter. This will be reflected in the Sling Documentation and the Sling Starter README. Implementation will follow in
Jira | ||||||
---|---|---|---|---|---|---|
|