leishman
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: How to config environment variables with Elixir and Exrm « Plataformatec Blog
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.
Most Liked
jwarlander
The difference is between ExRM and Distillery..
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.
AndrewDryga
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.
AndrewDryga
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








