Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Overwrite service properties using environment variables #144

Open
fxjordan opened this issue Aug 19, 2022 · 0 comments
Open

[ENH] Overwrite service properties using environment variables #144

fxjordan opened this issue Aug 19, 2022 · 0 comments

Comments

@fxjordan
Copy link

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:

web:
  image: nginx
  ports:
   - "8080:80"
  environment:
   - NGINX_HOST=foobar.com
   - NGINX_PORT=80

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:

  • Assume a class com.example.MyService with a field named myProperty.
  • las2peer searches for a file com.example.MyService.properties in certain directories
    private String findPropertyFile() {
  • 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):

gamificationFramework:
  image: registry.tech4comp.dbis.rwth-aachen.de/rwthacis/gamification:latest
  ports:
   - "8080:8080"
  environment:
   - GAMIFICATION_GAME_SERVICE_JDBC_URL=jdbc:postgresql://localhost:5432/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant