Nihilus-Ex

Nihilus-Ex

Best practice regarding configuration files for an app (iex -S mix & mix release)

Hello everyone ! :wave:

I’m new to the forum, even if I used it a lot when learning Elixir I never had the need to ask my own questions. I always found my answers there but not this time. That’s why I’m writing my first post :smile:

Here is the context: I have an Elixir application that I have always used by launching it via the command iex -S mix phx.server.

This app is an Umbrella app. Until now I had shared the configuration files between the different apps.

Recently I wanted to try switching to mix release with the Docker option. I had a lot of modifications to make but I finally managed to get my app working. I just have a few libraries that don’t work correctly because they use things not allowed in mix release but these are for “bonus” uses, let’s say.

However, I am not satisfied at the moment with what I have done. I copied/pasted all the contents of my config.exs, prod.exs and prod.secret.exs files into the runtime file. Then in my Dockerfile I copied only this file with a custom config.exs file which contains very little config.

My runtime file is currently 1500 lines long because it contains the configs of all my applications.

Is there another way to do it that is cleaner?

In fact I would like to be able to make my code coexist so that it is able to run my application both with iex -S mix and mix release.

What are the best practices regarding configs for an Umbrella application that must be able to work in both modes?

I’ve read a lot of different things about this, some delete app config files, others keep them so I’m not sure what the best method is.

NB: If I copy all my config files in the Dockerfile I need a ton of environment variables that are not accessible at build time (and therefore require the use of a secret file). This is why I created a configs file which only contains the minimum for compilation and which is only used for the mix release.

I thank all the people who will answer me and those who have already given me so many answers in the past :pray:

Most Liked

egze

egze

The questions to ask yourself are:

  1. Does it need to be in the Application config?
  2. Is the config different depending on the environment?
  3. Does it need to come from runtime envs?

Sorry for a non-answer :slight_smile:

Can you give us a couple of examples for the configs, and we can talk about some options for them?

Nihilus-Ex

Nihilus-Ex

These are indeed good questions that I could ask myself.

But for example:
Some people on the team put in the prod.secret.exs file configs containing values ​​that are supposed to be secret. However, these values ​​are actually retrieved from environment variables. So is it really useful to have a prod.secret.exs file in this case? Is there a benefit?

Then actually our production and development/test configs are indeed different. But is it a good practice to do it like this?

For example: Ecto configs, for dev/test they are written directly in the code, while in prod the values ​​are retrieved from env variables. But isn’t it better to only have one config in the root configuration which would read the values ​​via environment variables?

Or in dev/test algorithms used are less “heavy” than those used in production so the configurations are different. Is it not better to just have if test do this in the config file ? I’m just asking to be sure, I’m not saying this or that way is better.

Finally about the config per application in the case of our Umbrella app all applications must be launched/used. Hence my question regarding having config per application. Is it useful ? Is it better to separate them, to group them together at the root? If I specify a config for an application this configuration will be propagated to all the other apps anyway, right?

Anyway, thank you for your answer :smiley:

Where Next?

Popular in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
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
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement