I talk about how I really like to use runtime configuration and discuss some common pitfalls of configuration in Elixir.
This post is so helpful! Thanks a lot!
Especially I like the last part about using Code.require_file/2
. But I tried that and found it doesn’t work in my release app. It is due to the second parameter of Code.require_file/2 which is the relative file path. In my Dockerfile I copy only release output(under _build/prod/rel/) to my workdir, though there is no config/ directory. So I change the file path like that:
case config_env() do
:prod -> Code.require_file("runtime.prod.exs", __ENV__.file |> Path.dirname())
end
Then it works well. Anyway, thanks for the great post again!
Lots of great info I had no idea about! Thanks for sharing!
Hi @axelson
I have been following your blog post, but somehow I cannot start my app, I get the following error: Application testapp exited: shutdown Kernel pid terminated (application_controller) ("{application_terminated,testapp,shutdown}")
The code is the same as in your blog post.
When starting the app Core.require_file/2
returns []
. As it seems I am missing something, but don’t know what.
I have config/config.exs
config/runtime.prod.exs
config/runtime.test.exs
config/runtime.dev.exs
config/runtime.exs
config/config.exs
does not have the line to import other configs.
Please help.
Thanks!