You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's quite common for docker containers to support configuration by environment variables. las2peer uses service specific .properties files for configuration, which is fine. If we want to overwrite the complete configuration, we can use custom Docker volumes and overwrite the whole configuration file.
However, it would be comfortable if we are also able to overwrite only single properties (e.g., a database URL). This could be done using special environment variables.
If it exists, the value of the property myProperty in that file is used to initialize the myProperty field of the service object.
New behavior
First, the field value is resolved as before. Additionally, we check if there is an environment variable for the service property. If the variable exists, we overwrite the field value again.
There are different options for the naming style of the environment variables:
Use the full service class name, e.g., com_example_MyService_myProprty
Use only the simple class name, e.g, MyService_myProperty
Use one of the previous options, but in upper case, which is more common for environment variables, e.g., COM_EXAMPLE_MY_SERVICE_MY_PROPERTY or MY_SERVICE_MY_PROPERTY
7. Finalized state
For example, in the Gamification Framework, I'd be able to overwrite the database URL, which is specified in the file i5.las2peer.services.gamificationGameService.GamificationGameService.properties (property name jdbcUrl). I'd just need to define an environment variable as follows (docker compose syntax):
1. Motivation
It's quite common for docker containers to support configuration by environment variables. las2peer uses service specific
.properties
files for configuration, which is fine. If we want to overwrite the complete configuration, we can use custom Docker volumes and overwrite the whole configuration file.However, it would be comfortable if we are also able to overwrite only single properties (e.g., a database URL). This could be done using special environment variables.
Example from NGINX config in docker-compose:
5. Specification
The environment variables would be derived from the services class name and the field name in the class. Currently, the behavior is as follows:
com.example.MyService
with a field namedmyProperty
.com.example.MyService.properties
in certain directorieslas2peer/core/src/main/java/i5/las2peer/api/Configurable.java
Line 274 in 9fcd273
myProperty
in that file is used to initialize themyProperty
field of the service object.New behavior
First, the field value is resolved as before. Additionally, we check if there is an environment variable for the service property. If the variable exists, we overwrite the field value again.
There are different options for the naming style of the environment variables:
com_example_MyService_myProprty
MyService_myProperty
COM_EXAMPLE_MY_SERVICE_MY_PROPERTY
orMY_SERVICE_MY_PROPERTY
7. Finalized state
For example, in the Gamification Framework, I'd be able to overwrite the database URL, which is specified in the file
i5.las2peer.services.gamificationGameService.GamificationGameService.properties
(property namejdbcUrl
). I'd just need to define an environment variable as follows (docker compose syntax):The text was updated successfully, but these errors were encountered: