fxn

fxn

How to avoid duplicated build time vs releases configuration

(I have found some threads in the forum that in one way or another touch this topic, but none of them solves this question in a clear way.)

As you know, build time configuration is located in config/config.exs, Mix uses that file to generate the application resource file, which contains the hard-coded application environment, among other things.

On the other hand, we have now config/releases.exs, which is evaluated at runtime, but only for releases.

Now, in my project everything is set via system environment variables regardless of the type of server. So, for example I have

config :avrora, registry_url: System.fetch_env!("AVRO_REGISTRY_URL")

and a dozen others like that.

Is it correct that despite the intended uniformity, I have to repeat that line in config/config.exs and in config/releases.exs?

Is there a way to avoid that duplication? I was thinking about creating config/common.exs, to be imported in both files, but the docs for mix release say you cannot use import_file (does it mean import_config?).

Most Liked

josevalim

josevalim

Creator of Elixir

Exactly. There is a gap between config/config.exs and config/releases.exs, because one is compile-time and the other is runtime. That’s why it has been historically awkward to do runtime configuration for Mix. config/releases.exs solves it, but only for releases. We are aware of the issue and we have a proposal in draft, to be included on v1.11, that makes it clear what is compile-time and what is runtime. This should be the last stop in our journey to improve Elixir configs that started back in v1.9.

12
Post #8
josevalim

josevalim

Creator of Elixir

It is still in draft. It should be published in the upcoming week.

keathley

keathley

I’m the author of Vapor so obviously I’m biased. But my preference is to completely avoid all of the config/**.exs files for runtime configuration. Its way more trouble then its worth. Vapor is a formalization of the patterns that I’ve been using to manage configuration values in the services I maintain. The library itself has gone through a few different iterations but overall its been useful.

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
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

We're in Beta

About us Mission Statement