Set up Magnolia PaaS
This page guides you on setting up everything you need to set up a new Magnolia PaaS project.
Check you have the correct prerequisites, create your project, and then get ready to deploy your Magnolia PaaS project.
Prerequisites
There are a few things that you need before you can get started with developing for your Magnolia PaaS project.
Java
Currently, the minimum supported Java version for Magnolia PaaS is Java 11 (LTS).
Magnolia needs at least a Java Runtime Environment (JRE) to run. Check if there’s a version of Java already installed on your computer by opening the terminal or command prompt and typing java -version
in a terminal or command prompt. If the system reports a version number, Java is installed on your computer.
See the Certified stack page to confirm that the version installed is supported. |
If you don’t have Java on your computer, proceed to install it.
On Windows, you need a Java SE Development Kit (JDK). The Java Runtime Environment (JRE) is not enough because the Tomcat application server does not recognize it.
What is the difference?
-
JRE is for users who run Java programs on their computers.
-
JDK is for developers who write Java-based applications.
Download and install JDK. By default, JDK is installed at C:\Program Files\Java\jdk-<version>\. You can choose another location.
Check JAVA_HOME environment variable
-
Open the command prompt.
-
Type
set
and press ENTER. -
Find
JAVA_HOME
in the command output and verify that the path points to your JDK installation directory, for example,C:\Program Files\Java\jdk-<version>>.xx
. -
If
JAVA_HOME
is missing or it points to the wrong directory, see Set JAVA_HOME environment variable below.
Set JAVA_HOME environment variable
-
Right-click My Computer and select Properties.
-
Go to the Advanced tab.
(In Windows 7+, right-click Computer and select Advanced System Settings, then Environment variables.) -
If the
JAVA_HOME
environment variable does not exist in User variables or System variables, create it:-
User variables apply to the currently signed-in user only. Create
JAVA_HOME
here if you want it to apply only to the currently logged-in user. These variables take precedence over system variables. -
System variables apply to all users. Create
JAVA_HOME
here if you want it to apply to all users. You must be an administrator to modify a system environment variable.
-
-
Set the value of
JAVA_HOME
to the path of your JDK installation directory, for exampleC:\Program Files\Java\jdk-10.0.xx
. -
Optional step: Add the Magnolia
bin
directory to thePATH
variable, for example,C:\Program Files\magnolia\apache-tomcat-x.y\bin
. Setting thePATH
allows you to issue the Magnoliastart
andstop
commands from anywhere without navigating to the installation directory first. Separate the path from existing paths with a semicolon ( ; ). If you do this, you also need to addCATALINA_HOME
to environment variables. Set the value ofCATALINA_HOME
to the Tomcat installation directory, for example,C:\Program Files\magnolia\apache-tomcat-x.y
-
Click OK.
-
Go back to Check JAVA_HOME environment variable above and test that the variable is found and has the correct value. You need to open a new command prompt since environment variables are session specific.
Alternatively, you can set JAVA_HOME with a batch file. Add this line to
/apache-tomcat/bin/magnolia_control.bat
:
set JAVA_HOME=C:\Program Files\Java\jdk-<version>>.xx
The set
command creates the JAVA_HOME
environment variable and sets
its value to the JDK directory. The command is executed when Magnolia
starts.
For Mac, you need to download or update to Java 11 or higher. After reviewing and agreeing to the terms of the license agreement, download the file, then double-click it to launch the installation wizard and follow the installation instructions.
The installation directory varies from one Linux system to another. On Debian-based distributions, JREs or JDKs are usually installed in /usr/lib/jvm/
.
Maven
Download and Install Maven 3. Follow the OS-specific installation instructions from the Maven website (e.g. setting PATH environment variable).
In order to verify Maven has been installed correctly:
Open a terminal or a shell and run:
`mvn -v`
Maven keeps your user configuration and local repository under th ${user.home}/.m2/ directory .
|
Setting up credentials
To encrypt your Nexus credentials, execute the following command in your terminal or shell
mkdir -p ~/.m2 ; read -s -p 'Please enter your master Maven password: ' MASTPASS && \
echo "<settingsSecurity><master>`mvn --encrypt-master-password $MASTPASS`</master></settingsSecurity>" > ~/.m2/settings-security.xml ; \
unset MASTPASS
After you have set up Password Encryption above, switch to your shell and run the following command:
mvn org.sonatype.plugins:nexus-m2settings-maven-plugin:1.6.5:download -DnexusUrl=link:https://nexus.magnolia-cms.com -DtemplateId=magnolia-enterprise
Testing Maven settings
A simple way to test your settings: Try to build a project with Maven which is dependent on a Magnolia Enterprise module. Try to build a DX Core bundle from the Magnolia official Maven archetypes:
mvn archetype:generate -Dfilter=info.magnolia.maven.archetypes:magnolia
Mirroring
If you have your own Repository Manager, the following are the repositories you can mirror:
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.public.releases/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.public.snapshots/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.public.maintenance.releases/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.public.maintenance.snapshots/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.enterprise.releases/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.enterprise.snapshots/
-
https://nexus.magnolia-cms.com/content/repositories/thirdparty.customized/
-
https://nexus.magnolia-cms.com/content/repositories/thirdparty.licensed/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.forge.releases/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.forge.snapshots/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.addons.releases/
-
https://nexus.magnolia-cms.com/content/repositories/magnolia.incubator.releases/
|
Create a project using the Maven archetype
Create a custom cloud bundle from the following Maven Archetypes:
mvn archetype:generate \
-DarchetypeGroupId=info.magnolia.maven.archetypes \
-DarchetypeArtifactId=magnolia-dx-core-custom-cloud-archetype \
-DarchetypeVersion=1.7 \
-DarchetypeRepository=https://nexus.magnolia-cms.com/content/repositories/magnolia.public.releases
You will be prompted to enter the following info:
-
groupId
: The Maven groupId of your cloud bundle (ie: info.magnolia.demo) -
artifactId
: The Maven artifactId of your cloud bundle (ie: magnolia-demo-ecommerce) -
version
: The Maven version of your cloud bundle (ie: 1.0-SNAPSHOT). The final version is generated on release. -
package
: The Maven base package of your cloud bundle (usually same a thegroupId
) -
magnolia-bundle-version
: The Magnolia version to be used in your cloud bundle (ie: 6.2.39) -
project-name
: The project name (ie: magnolia-demo-ecommerce) -
shortname
: The name of the project to be used in the Magnolia URLs (ie: https://dev.shortname.magnolia-platform.com/author) -
region
: The AWS region the database backup bucket is located in (ie: eu-central-1)
The command will then create the Magnolia Java Webapp project.
The Java webapp in Magnolia PaaS has a typical structure.
custom
├── .gitignore
├── .gitlab-ci.yml (1)
├── .m2
│ └── settings.xml
├── README.md
├── custom-webapp
│ ├── Dockerfile
│ ├── pom.xml
│ ├── src
│ └── target
├── pom.xml
└── values.yml (2)
1 | The .gitlab-ci.yml file ensures your development changes are automatically picked up. |
2 | The values.yml file ensures your Magnolia PaaS application is deployed to the your cluster. |
On the first level you will find the pom.xml
file which automatically contains the magnolia-dx-core-custom-cloud-parent
artifact.
...
<dependencyManagement>
<dependencies>
<!-- DX Core custom cloud dependency management -->
<dependency>
<groupId>info.magnolia.dx</groupId>
<artifactId>magnolia-dx-core-custom-cloud-parent</artifactId> (1)
<version>${magnolia.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
1 | The magnolia-dx-core-custom-cloud-parent artifact. |
Testing the project
Open a terminal and go to the newly created project and then execute the following Maven build command:
mvn clean package
Starting Magnolia locally
Load the project in your IDE and configure the Tomcat server with the following system variables.
-Xms1024m
-Xmx2048m
-Dmagnolia.develop=true
-Dmagnolia.superuser.enabled=true
-Dmagnolia.utf8.enabled=true
-Dmagnolia.update.auto=true
-Dmagnolia.resources.dir="/opt/magnolia/light-modules"
-Dmagnolia.repositories.home="/opt/magnolia/repositories"
-Dmagnolia.webapp="Goofy Author"
-Dmagnolia.inject.config="createPath:/modules/enterprise/license\;setProperty:/modules/enterprise/license,owner,
your_email\;setProperty:/modules/enterprise/license,key,your_license_hash“
Custom cloud parent project
The custom cloud parent project automatically excludes the following modules:
-
Backup module: It will be part of an outside feature.
It includes the following modules:
-
Instrumentation: Exposes the Magnolia metrics to the monitoring service.
-
Configuration injection: Facilitates the customization of Magnolia.