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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
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
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
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
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
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
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
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
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
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
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
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
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement