0
votes

I have all my configuration set into application.conf which locates under src/main/resources. and it works fine when I run my app in production mode.

val config = ConfigFactory.load()

In some certain situation when I run my app in docker container and I need to override about 30 of properties.

When I add

-Dconfig.file="/etc/deployed.conf"

it excludes all original properties which contains "application.conf" and are not overriden in "deployed.conf".

Is there any way to solve this issue?

Update: Will

val myCfg =  ConfigFactory.parseFile(new File("etc/deployed.conf"))
val config = ConfigFactory.load().withFallback(myCfg)

override values in application.conf and will not throw any exception if this file does not exist?

1
maybe add .withFallback - Roby
Have you tried renaming deployed.conf to application.conf just to see if there's a convention issue? Also, I'd set the -Dconfig.trace=loads flag and monitor stderr to see if there any resolution issues. - Yuval Itzchakov
@Roby see my update - danny.lesnik
@YuvalItzchakov I renamed external config as you suggested and added trace, it looks application.conf is ignored. it goes to external conf and then to reference.conf inside akka jars. - danny.lesnik
It actually parses your external conf? - Yuval Itzchakov

1 Answers

0
votes

If you create it manually you can use the withFallback method.

Config appConfig = ConfigFactory.parseResources(configs.remove(0));
for (String resource : configs) {
    appConfig = appConfig.withFallback(ConfigFactory.parseResources(resource));
}