smon

smon

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?

Showing Posts 1 to 6

trisolaran

trisolaran

Hi @smon,

apps under an umbrella share the same configuration and releases.exs.

What is exactly the issue here? If I’m reading your code snippet correctly, host_url is part of the configuration of your my_api app, and other apps in the umbrella won’t even care.

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.

smon

smon OP

The release.exs gets incorporated into all builds. This results in a System.fetch_env!("HOST") call on startup/runtime for all apps and an exception for those apps where HOST is not set.

smon

smon OP

That’s it, thanks. But I need to rename my release.exs to something non-standard. Thanks!

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 OP

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:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews