Magnolia Code Server Documentation
Providing a Docker container for Magnolia Development from many aspects, using various Arguments to set it up in the way you desire.
With the vast array of system architectures, many scenarios can lead to issues getting a proper environment up-and-running. This is a solution to remove those potential road-blocks.
This Dockerfile
is widely diverse, providing you with the ability to use it for purely frontend development, or for your more advanced use-cases, backend development in addition to all the frontend capabilities. This document will provide you with all the configurations available to produce the exact architecture you need.
Introduction
You can get the project code from the Magnolia Code Server Git repository.
Once you have the project, you can browse the available examples in the servers
directory, or simply create your own within a new folder, and defining the arguments
in the docker-compose.yml
file. For example, if you want the most minimalistic environment (Code Server, Magnolia Community Demo Webapp Edition via Jumpstart), your docker-compose.yml
file would look like this:
version: '3.3'
services:
minimal-code-server:
build:
context: ../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
ports:
- "8443:8443"
- "8080:8080"
If you are using Apple Silicon (Apple M1+), you should check out Install with Multipass to set up Multipass to work natively instead of using Rosetta. |
Once you run docker-compose up
from servers/my-docker-container
, you would be able to access the Code Server from http://localhost:8443/
, where you could start up Magnolia using mgnl jumpstart
from the magnolia
directory. If you have deployed this container someplace other than your localhost
, just modify that with the IP.
The following section will walk you through the various configurations you can use either in a docker-compose.yml
file, or by docker build
. When you are familiar with the configuration arguments, you can take a look at Example Servers to help guide you to build the server that’s right for you.
Arguments
Below is a list of the arguments that you can use to define your Docker container. You can also jump directly to Frontend Development Arguments or Backend Development Arguments.
General Settings
These settings apply to any type of Code Server. All Code Servers are deployed on the Ubuntu 20.04 platform, will come with Visual Studio Code Server’s web-based IDE, a JDK of your choosing, NodeJS, and Magnolia’s CLI. Additionally, the VSCode server will be populated with several extensions to make development even easier. These are the extensions that are provided for all Code Servers:
-
Freemarker/Magnolia/HTML Snippets
-
Freemarker
-
Tomcat for Java[1]
-
YAML
-
GitLens — Git supercharged
-
Prettier - Code formatter
-
indent-rainbow
-
VS Code Java Pack
Argument | Description | Default Value | Options/Type | ||
---|---|---|---|---|---|
|
The user account name that will be used to access the server. This account does not have |
magnolia |
String |
||
|
The group that the user will be assigned. |
magnolia |
String |
||
|
The user password for access to the server. |
magnolia |
String |
||
|
The CPU used by the system.
|
amd64 |
|
||
|
The Time Zone applied to the server. See |
Etc/UTC |
String |
Argument | Description | Default Value | Options/Type |
---|---|---|---|
|
The version of VSCode Server. See coder/code-server on GitHub for available releases. |
4.6.1 |
Version String |
|
The type of authorization for accessing Code Server. Further configurations will come, at this time, only a simple password can be configured. |
password |
|
|
When |
magnolia |
String |
Argument | Description | Default Value | Options/Type | ||
---|---|---|---|---|---|
|
The version of NodeJS to install. |
14 |
|
||
|
The version of Java to install to the system.
|
11 |
|
||
|
The JDK Provider. |
openjdk |
|
||
|
The GraalVM version to use, if you choose |
22.2.0 |
|
You should always, at a minimum, set the SYSPASSWORD and PASSWORD properties.
|
In the following sections, you will see that there are several arguments that are shared between both types of deployments.
Frontend Development Arguments
This section will provide you with an overview of configuration for the frontend code server. If you’d like information on how to use the server, you can jump directly to Frontend Code Server
Argument | Description | Default Value | Options/Type | ||
---|---|---|---|---|---|
|
Set’s the type of development environment to target.
|
"frontend" |
|
||
|
This is the type of Magnolia Server you would like to install.
|
magnolia-community-demo-webapp |
|||
|
The version of Magnolia that you wish to |
6.2.23 |
Version String |
||
|
This is your LDAP user that gives you access to the Magnolia Nexus repository. This will be required if you are using any DX Core version of Magnolia. |
"anonymous" |
String |
||
|
This is your LDAP password that gives you access to the Magnolia Nexus repository. This will be required if you are using any DX Core version of Magnolia.
|
"anonymous" |
String |
||
|
If you wish to include the Backend Live extensions, you can set this to |
"false" |
|||
|
Along with using Backend Live extensions, you can also include some sample Backend Live Light Modules |
"false" |
|||
|
It is unlikely that you would need to change this repository location, unless you have an alternative set of sample light modules.
|
"https://git.magnolia-cms.com/scm/light-modules/backend-live-samples.git" Browse the Repo |
URL |
||
|
This will install the Headless Accelerator. Currently, you will have to follow the steps in the previous link in order to complete the installation process. |
"false" |
|||
|
If you wish to install HA, you will need to provide this property until HA-130 is resolved. If you would like to find out how to get your Authentication Token, see Get Nexus Authorization Token |
Null |
Your authentication token. |
Backend Development Arguments
This section will provide you with an overview of configuration for the backend code server. If you’d like information on how to use the server, you can jump directly to Backend Code Server
Argument | Description | Default Value | Options/Type | ||
---|---|---|---|---|---|
|
Set’s the type of development environment to target. For a Backend Code Server, it is required to set this to |
"frontend" |
|
||
|
This is the type of Magnolia Server you would like to install. The build scripts will use the Magnolia Maven Archetype to generate a parent project containing a webapp project. Node scripts are used to modify the POM files to match your selection. If you choose an edition that contains
|
magnolia-community-demo-webapp |
|
||
|
The version of Magnolia that you wish to create. |
6.2.23 |
Version String |
||
|
This is your LDAP user that gives you access to the Magnolia Nexus repository. This will be required if you are using any DX Core version of Magnolia. |
"anonymous" |
String |
||
|
This is your LDAP password that gives you access to the Magnolia Nexus repository. This will be required if you are using any DX Core version of Magnolia.
|
"anonymous" |
String |
||
|
The URL used to clone your desired Git repository.
|
URL |
|||
|
The Apache Tomcat version you prefer to use. Apache will remove old versions of Tomcat from time-to-time, so it is good to check Tomcat’s Download Page if you get an error on build. |
9.0.65 |
Version String |
||
|
If you provide your Nexus credentials, the Docker build will generate the appropriate |
"false" |
|||
|
This value will apply to your project’s |
info.magnolia.dev |
String |
||
|
The name of the Magnolia project. This is the name of the |
magnolia-dev-project |
String |
||
|
The class name of the Magnolia Module. |
magnolia-dev-project |
String |
||
|
If this server is a public server, set value to |
|
String |
||
|
If you have a public server, you need to modify the bootstrap file to point to the appropriate public server(s). If you have modified a bootstrap file, set this to |
|
String |
||
|
If you wish to include the Backend Live extensions, you can set this to |
"false" |
|||
|
Along with using Backend Live extensions, you can also include some sample Backend Live Light Modules |
"false" |
|||
|
It is unlikely that you would need to change this repository location, unless you have an alternative set of sample light modules.
|
"https://git.magnolia-cms.com/scm/light-modules/backend-live-samples.git" Browse the Repo |
URL |
||
|
This will install the Headless Accelerator. Currently, you will have to follow the steps in the previous link in order to complete the installation process. |
"false" |
|||
|
If you wish to install HA, you will need to provide this property until HA-130 is resolved. If you would like to find out how to get your Authentication Token, see Get Nexus Authorization Token |
Null |
Your authentication token. |
Example Servers
The server configurations provided in the servers
folder are examples to help guide you to build the system that best suits your needs and Use Case. You can try different configurations as you wish. The easiest way to build a system is using docker-compose
, although you are free to build images with docker
.
Building with DXCore
When using DXCore, you will need to provide your Nexus credentials in order to properly access the DXCore resources.There are two properties, NEXUS_USER
and NEXUS_PW
to set these.These properties should never be set in your YAML file, in case you accidentally check this in.Instead, you can set these values on the build command like this:
export NEXUS_PW=YOUR PASSWORD
docker-compose build --build-arg NEXUS_USER=srhodes --build-arg NEXUS_PW=$NEXUS_PW
For use of the Headless Accelerator, there is one additional argument that is currently necessary, MGNL_HA_AUTH_TOKEN
.You can find your token by following the instructions at Get Nexus Authorization Token
For these builds, just add it to the build command:
export NEXUS_PW=YOUR PASSWORD
export MGNL_HA_AUTH_TOKEN=YOUR ACCESS TOKEN
docker-compose build --build-arg NEXUS_USER=srhodes --build-arg NEXUS_PW=$NEXUS_PW --build-arg MGNL_HA_AUTH_TOKEN=$MGNL_HA_AUTH_TOKEN
Frontend Code Server
A Frontend Server will make use of the Magnolia CLI to jumpstart
a Magnolia server with an Author and a Public instance.Once your server is up, simply open a terminal in VSCode Server, navigate into the magnolia
folder, and run mgnl start
.
The following are meant to serve as an example for your development server, but can be configured more specifically to meet your Use Case.
The Vanillaist
This is about as simple as the frontend servers come. You can find the prepared server in this project at servers/frontend/frontend-default-jdk11/docker-compose.yml
. It’s going to provide you with a basic magnolia-community-webapp
server. As usual, we suggest you override the passwords, as the default value is always magnolia
. In this example, we’re making it just slightly less generic, so you should get slightly more inventive for your actual implementation. If you use a docker-compose.yml
file, this is how it would look:
version: '3.3'
services:
minimal-code-server:
build:
context: ../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
ports:
- "8443:8443"
- "8080:8080"
Then, in the directory, simply run docker-compose up
from the directory containing your YAML file.
Working with Backend Live
In the example servers, we have two examples. One is using the community edition, and the other is using DXCore. There is one other configuration available, where you could use the GraalVM JDK instead of the OpenJDK installation. We will discuss those configurations. Here is an example of a server using OpenJDK 11, Magnolia Community Edition, and some sample Backend-Live Light Modules:
version: '3.3'
services:
frontend-default-jdk11-backendlive:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
BACKEND_LIVE: "true"
BACKEND_LIVE_SAMPLES: "true"
ports:
- "8443:8443"
- "8080:8080"
Then, in the directory, simply run docker-compose up
from the directory containing your YAML file.
If you prefer to use DXCore, the YAML file only needs one more attribute, and would look like this:
version: '3.3'
services:
frontend-dxcore-jdk11-backendlive:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
BACKEND_LIVE: "true"
BACKEND_LIVE_SAMPLES: "true"
WEBAPP_EDITION: magnolia-dx-core-demo-webapp
ports:
- "8443:8443"
- "8080:8080"
One last configuration that could be interesting is using an alternative JDK, specifically the GraalVM provided JDK. Here is an example of how to configure that.
version: '3.3'
services:
frontend-dxcore-graalvm-11-backendlive:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
JDK_VERSION: graalvm-ce-java11-22.2.0
BACKEND_LIVE: "true"
BACKEND_LIVE_SAMPLES: "true"
WEBAPP_EDITION: magnolia-dx-core-demo-webapp
ports:
- "8443:8443"
- "8080:8080"
Working with HA
This is still undergoing implementation. At this time, you are only installing the HA CLI, and building a separate Magnolia instance. |
Since HA requires the use of DX Core, we will specify the DXCore WEBAPP_EDITION
. You could also change this to magnolia-dx-core-demo-webapp
if you wish to have the travel demo and some example content loaded. Remember, this is going to change as this server is not currently used by HA as of version 1.0.6.
version: '3.3'
services:
frontend-dxcore-jdk11-ha:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
WEBAPP_EDITION: magnolia-dx-core-webapp
HA: "true"
ports:
- "8443:8443"
- "8080:8080"
- "3000:3000"
Then, in the directory, simply run docker-compose up
from the directory containing your YAML file.
Backend Code Server
The primary difference between a Frontend Server and the Backend Server is that most of the Backend Servers use Maven to build the Magnolia Webapp. Additionally, by default, there will only be a single Author webapp and no Public servers. This gives you the ability to develop your backend functionality.
With Backend Servers, Maven is also installed to manage dependencies and build your webapp. When the server is built, the Magnolia Maven Archetype to build a parent project that maintains a webapp project. With the VSCode extensions, you will be able to run your server, debug the source code, and even perform Hot Code Replacement.
Deploying your Webapp
With Frontend Servers, you would start Magnolia using the Magnolia CLI. With Backend Servers, you will use the Apache Tomcat VSCode Extension.
To do so, you first would add Tomcat to the configuration by:
-
Click the
+
in the Tomcat Servers -
Point to
/home/magnolia/tomcat/apache-tomcat-${VERSION}
Now you will want to modify the JVM settings, which is fortunately quite simple. Just right-click on the new server, then click Customize JVM Options
.
This will open a file, where you will add your customizations. The minimum customizations would look like this:
-Dmagnolia.repositories.home=/home/magnolia/repositories
-Dmagnolia.resources.dir=/home/magnolia/workspace/light-modules
This just changes the locations for the JCR Workspace, and the location for your Magnolia Resources where frontend development will take place.
If you are using JDK 17 and above, you would also need to add a flag to deal with some JDK issues like this:
--add-opens java.base/java.lang=ALL-UNNAMED
-Dmagnolia.repositories.home=/home/magnolia/repositories
-Dmagnolia.resources.dir=/home/magnolia/workspace/light-modules
Next, you will need to add your Webapp to the Server. The Webapp is located in your project within the *-webapp/target
directory. You can either add the .war
file or the folder with the same name. If you plan to do Hot Code Replacement, you need to use the "exploded" (non .war folder).
Just right-click on your webapp, and then click Debug on Tomcat Server
. This will automatically start the deployment.
You can use the following examples to guide you in building the exact Backend Server to fit your needs.
Default Community Edition
The default Magnolia configuration, if left undefined, is the magnolia-community-webapp
. You can find the prepared server in this project at servers/backend/backend-ce-jdk11/docker-compose.yml
. As usual, we suggest you override the passwords, as the default value is always magnolia
. If the version of the JDK is left unspecified, it will install Open JDK 11. Also, installed is Maven version 3.8.6
and Tomcat 9.0.65
. If you run into issues on building a Backend Server, and the error occurs during the Tomcat installation, please check Tomcat’s Download Page as Apache doesn’t always maintain older versions.
It is also a good idea to override the MODULE_*
properties as these will be the name of the generated project.
The WEBAPP_EDITION
use the same naming convention as the Frontend Servers for convenience. There is some magic tricks added to take this edition to modify the POM’s of the parent and webapp projects. Basically, the POM’s are modified to point to the proper dependencies to use community, dxcore, and even add the travel demo modules if you indicate a *-demo-webapp
edition.
In this example, we’re making it just slightly less generic, so you should get slightly more inventive for your actual implementation. If you use a docker-compose.yml
file, this is how it would look:
version: '3.3'
services:
backend-ce-jdk11:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
DEV_PERSPECTIVE: backend
WEBAPP_EDITION: magnolia-community-webapp
MODULE_GROUP_ID: info.magnolia.demo
MODULE_CLASS_NAME: MyDemoModule
MODULE_NAME: magnolia-dev-demo-project
ports:
- "8443:8443"
- "8080:8080"
Then, in the directory, simply run docker-compose up
from the directory containing your YAML file.
If you would like to include the travel demo with example content, simply change WEBAPP_EDITION: magnolia-community-webapp
to WEBAPP_EDITION: magnolia-community-demo-webapp
.
DXCore Edition
This example is nearly identical to the previous example, but uses DXCore. Here is the YAML configuration:
version: '3.3'
services:
backend-dxcore-jdk11-ha:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
DEV_PERSPECTIVE: backend
WEBAPP_EDITION: magnolia-dx-core-webapp
MODULE_GROUP_ID: info.magnolia.demo
MODULE_CLASS_NAME: MyDemoModule
MODULE_NAME: magnolia-dev-demo-project
ports:
- "8443:8443"
- "8080:8080"
The big difference is that you will need to provide your Nexus Credentials as shown in Building with DXCore.
Just like in the previous example, if you’d like to add the travel demo modules and sample content, just change WEBAPP_EDITION: magnolia-dx-core-webapp
to WEBAPP_EDITION: magnolia-dx-core-demo-webapp
.
Add Backend Live
If you’d like to use the experimental Backend Live functionality, you can do so by following this example:
version: '3.3'
services:
backend-dxcore-jdk11-backendlive:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
DEV_PERSPECTIVE: backend
BACKEND_LIVE: "true"
BACKEND_LIVE_SAMPLES: "true"
WEBAPP_EDITION: magnolia-dx-core-demo-webapp
ports:
- "8443:8443"
- "8080:8080"
This example also adds BACKEND_LIVE_SAMPLES
which are a collection of Light Modules showing the various capabilities like custom Actions, Availability Rules, UI elements, and Commands.
Since Backend Live uses Javascript Models 2, you are now able to work with more modern JDK’s. You can configure your Backend Server to use JDK 17, for example by using the following YAML configuration:
version: '3.3'
services:
backend-dxcore-jdk17-backendlive:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
DEV_PERSPECTIVE: backend
JDK_VERSION: java-17-openjdk-amd64
BACKEND_LIVE: "true"
BACKEND_LIVE_SAMPLES: "true"
WEBAPP_EDITION: magnolia-dx-core-demo-webapp
ports:
- "8443:8443"
- "8080:8080"
Using a Git Repo
If you prefer to use an existing Git Repository rather than building a new Maven project, you can do so with the following configuration:
version: '3.3'
services:
fullstack-training-git:
build:
context: ../../../
args:
PASSWORD: magnolia123
SYSPASSWORD: magnolia123
DEV_PERSPECTIVE: backend
WEBAPP_EDITION: git-project
GIT_PROJECT: https://USER_NAME:PASSWORD@git.magnolia-cms.com/scm/training/training-fullstack-project.git
COPY_MVN_SETTINGS_XML: "true"
ports:
- "8443:8443"
- "8080:8080"
There are some points of interest to discuss here. First, the Git Project depends on having a valid login. If you have anonymous access, you can simply remove this. Also, in this example, we are adding COPY_MVN_SETTINGS_XML
. This is a special scenario that would use a previously built settings.xml
for your Maven settings, moving it from the install-resources
folder to your built docker image.
More Information
Here you will find clarification of configurations above.
Why add my local settings.xml?
The Magnolia org.sonatype.plugins:nexus-m2settings-maven-plugin:1.6.8:download
mvn function used to generate a Maven project is not compatible with JDK 17, so if you try to generate the settings.xml file, it will fail. Until this is resolved, you can simply copy your local copy of settings.xml
to the install-resources
directory, and the mvn call will be ignored.