MicroProfile Config
MicroProfile Config defines a set of supported default ConfigSources
for environment variables, system properties, and META-INF/microprofile-config.properties
files on the classpath with specific ordinals.
SmallRye Config library
Magnolia can scan more locations for configuration properties files and uses the SmallRye Config library for implementation.
It supports passing such locations through the magnolia.config.locations
configuration property, which is defined as a system or environment property.
-Dmagnolia.config.locations=../WEB-INF/config/default/microprofile-config.yaml
To specify the path on Windows, write it as a URI, as shown below.
-Dmagnolia.config.locations=file:///c:/magnolia/.../WEB-INF/config/default/microprofile-config.yaml
You can also specify locations via magnolia.properties file
|
This enables developers to build containerized images of Magnolia once, and deploy anywhere; for example, when using Docker bind mounts or Kubernetes ConfigMaps.
Setting different profiles in MicroProfile Configs
Using profile-specific property names, you can support different profiles for author and public instances. For example, you might have different public instances for your intranet and the internet.
In the example MicroProfile configuration file below, when mp.config.profile
is set to intranet
, one receiver is returned: magnoliaPublic8080
.
However, when set to internet
, two receivers, magnoliaPublic-0
and magnoliaPublic-1
, are returned.
mp.config.profile=internet
%intranet.magnolia.publishing.receivers[0].name=magnoliaPublic8080
%intranet.magnolia.publishing.receivers[0].url=http://localhost:8080/magnoliaPublic
%intranet.magnolia.publishing.receivers[0].enabled=true
%internet.magnolia.publishing.receivers[0].name=magnoliaPublic-0
%internet.magnolia.publishing.receivers[0].url=http://dev-magnolia-helm-public-0-svc:8080
%internet.magnolia.publishing.receivers[1].name=magnoliaPublic-1
%internet.magnolia.publishing.receivers[1].url=http://dev-magnolia-helm-public-1-svc:8080
It’s also possible to have separate configurations at the config source level.
For example, one microprofile-config.properties for properties that aren’t profiled and another microprofile-config-<PROFILE_NAME>.properties for development profile properties.
|