Details
-
Improvement
-
Resolution: Fixed
-
Normal
-
None
-
None
-
None
-
-
Empty show more show less
-
Yes
-
Yes
-
TE 1, TE 2, TE 3
-
5
Description
Introduce profile based configuration
Background
Follow-up and align with proposal from ONDEMAND-2649;
- Approach should be mostly applicable to defaults in magnolia-core: info.magnolia.init.DefaultMagnoliaPropertiesResolver#DEFAULT_INITIALIZATION_PARAMETER
- and/or to magnolia-empty webapp (default properties files)
Current situation
By default Magnolia property files are resolved based on the host name, context path and name of the webapp. This default is specified in DefaultMagnoliaPropertiesResolver#DEFAULT_INITIALIZATION_PARAMETER and can be overridden via the magnolia.initialization.file context parameter.
Proposal
Introduce an alternative way to resolve Magnolia property files based on profiles. A profile is simply a name that can be further parametrized on the instance type and deployment stage. For profile based configuration we would change magnolia.initialization.file to something along the lines of
WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.${env/MAGNOLIA_STAGE}.properties, WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.properties, WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia.properties, WEB-INF/config/default/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.${env/MAGNOLIA_STAGE}.properties, WEB-INF/config/default/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.properties, WEB-INF/config/default/magnolia.properties
The profiles dev and cloud are reserved for development and cloud profiles, respectively. We include defaults for them for explicitness and convenience. The dev profile should simplify local development and we could draw inspirations from the dev webapp. The cloud profile should simplify Magnolia cloud deployments and cover ONDEMAND-2649 as much as possible.
Related concerns
- Magnolia should log activated profiles and failures to resolve them to facilitate debugging.
- Handling of non expanded $(variables) in DefaultMagnoliaPropertiesResolver should be improved: such configuration sources should be skipped explicitly instead of attempting resolution with the literal, non expanded name.
- DefaultMagnoliaPropertiesResolver relies on PropertiesInitializer#processPropertyFilesString, which is deprecated. We could replace this method with a new implementation.
Compatibility
- Profile based configuration must be explicitly enabled (command line argument, environment variable, context or init property)
- Consider deprecating the server based configuration in favour of profile based configuration. Sketch a migration path for those who still rely on server based configuration.
Potential further improvements
- The dev profile could be treated specially and include non resource files (e.g. from ~/.magnolia).
- Cloud native ways for injection the configuration. E.g. AWS Systems Manager Parameter Store.
If considered worthwhile we should discuss implications such as additional complexity, security, etc. of in follow up tickets.
Checklists
Attachments
Issue Links
- is related to
-
MAGNOLIA-7811 Remove deprecated configurations style based on server and app name
-
- Accepted
-
- split to
-
MAGNOLIA-7805 Cloud native configuration for Magnolia bundles
-
- Closed
-
-
MAGNOLIA-7804 Make system properties and environment variables injectable
-
- Closed
-
-
MAGNOLIA-7809 Allow magnolia profile to be specified via system property
-
- Closed
-
-
MAGNOLIA-7810 Fail when specified configuration profile doesn't exist
-
- Closed
-
- to be documented by
-
MAGNOLIA-7821 DOC: Environment variable for profile-based configuration
-
- Closed
-