smon

smon

How to add an app specific releases.exs configuration in umbrella project?

I am currently writing my first umbrella project. One of my apps is an API and I use a basic releases.exs to set its HOST domain using an environment variable:

import Config

config :my_api,
  host_url: System.fetch_env!("HOST")

The downside: Now all other release builds expect a HOST variable, which is unnecessary. What is the recommended pattern for this? I want to enforce the check in my API app, so currently I just add an unused HOST variable for all the other apps.

Any suggestions?

Marked As Solved

LostKobrakai

LostKobrakai

From the docs of mix release:

You can change the path to the runtime configuration file by setting :runtime_config_path inside each release configuration. This path is resolved at build time as the given configuration file is always copied to inside the release:

releases: [
  demo: [
    runtime_config_path: ...
  ]
]

You could therefore maintain multiple configs if one doesn’t suite your needs.

Also Liked

trisolaran

trisolaran

Thanks for the clarification.

My view is that if you need multiple apps that have to be started independently with different environments, then an umbrella app is probably not the right idea :slight_smile:

I think there are different use cases for umbrella apps, but to me the typical one is when you have a number of apps depending on each other and that have to be started as a whole. In this case it makes sense and it’s more convenient to have a single configuration and a single environment to start the whole application bundle (by a similar token, when you install a hex package the application in the package also shares the same configuration with your main app).

Creating an umbrella app and then splitting the start-up and configuration logic feels like an anti-pattern to me - probably better to split the apps into multiple stand-alone ones which you can then start independently.

smon

smon

I get what you mean, maybe some background:

In my case the apps are closely coupled in the sense that, code wise, they are all using one central “core”-app that is also in the umbrella. I want to ensure that all apps are kept aligned with each other, running their tests on the same “core” app code.

Originally, I had only one app that managed everything (-> one single supervision tree). But I want the API app, for example, to run really stable, and be completely independent of data aggregators that harvest external resource over the net and are more prone to errors.

So I moved to an umbrella project (-> API has now its own supervision tree).

I could of course move further and split everything up into separate repositories, but then I have more hassle keeping everything aligned and tested. I’d rather have one separate runtime configuration for the time being. :wink:

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
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
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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
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
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
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

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
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
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
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
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement