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

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
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
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
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
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
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
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
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

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
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
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement