leishman

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: http://blog.plataformatec.com.br/2016/05/how-to-config-environment-variables-with-elixir-and-exrm/

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

jwarlander

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.

AndrewDryga

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

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.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement