Runtime configuration with edeliver and distillery

I’m trying to use distillery and edeliver to deploy and run run a phoenix app in production. I build on a staging server (with one configuration) and deploy to a production server (with a different configuration). I want to provide these different runtime configurations via ENV variables.

Right now, using the format:

config :my_app, MyApp.Endpoint,
  http: [port: {:system, "HTTP_PORT"}],
  url: [host: {:system, "HOST"}, port: {:system, "URL_PORT"}]

works for the phoenix configs, but not for the ecto/db configs.

At runtime, Postgrex fails to understand this configuration syntax. I tried using the format:

config :my_app, MyApp.Repo,
  adapter: Ecto.Adapters.Postgres,
  hostname: "${DB_HOSTNAME}",
  username: "${DB_USERNAME}",

for my DB configs but this does not work as the strings remain as seen and are not replaced with my ENV variables at runtime.

I’ve read this blog post:

but it seems that the ${} format does not work with edeliver??

I’d prefer to not have to deal with creating separate sys.conf files and linking them. What is the proper way to handle all of this? Thanks.

The difference is between ExRM and Distillery… :sunglasses: Instead of RELX_REPLACE_OS_VARS=true, try REPLACE_OS_VARS=true.

It’s mentioned for vm.args in the Distillery docs, but definitely applies to sys.config as well.

1 Like

For people that found this article by googling it - I’ve written an article on configuration and deployments topic, checking it out.

Also, try reading Distillery docs, they are pretty comprehensive.

1 Like

I’ve seen you mention vault in an ecto thread once (and in the article), have you had any success with using it for configuration?

Thank you for the article btw.

I’ve rewritten Confex to support configuration adapters and started writing a Vault adapter for it. But then we postponed this task to the later development stages to concentrate on more important things for the project.

1 Like