bryanhuntesl

bryanhuntesl

Elixir releases on read-only file system.. Use confex instead of releases.exs?

There’s a bit of a trend in deployments these days to deploy containers with read-only root filesystems.

All the storage is off into (NO)SQL databases or cloud storage.

I was quite keen on Confex because it’s templating mechanism (interpolating environment variables at runtime via special app configuration syntax like {:system, "ENV_NAME", default}) allowed one to deploy on a read-only filesystem.

But, for some reason, the community didn’t adopt Confex - and everyone used the default release mechanism (releases.exs).

Now I find myself in the situation that many customer security teams are demanding apps are runnable with the security constraint that they can run on read-only file systems.

The average application reads in about 10~15 values from environment variables and I want to have one place that developers can consult to ensure all values are set rather than arbitrarily loading env values throughout the codebase.

Can anyone suggest a workaround - or should I just rewrite everything to use Confex?

First 10 of 20 Posts Switch mode

LostKobrakai

LostKobrakai

Maybe waiting for 1.11 is an option:

https://github.com/elixir-lang/elixir/blob/master/CHANGELOG.md#configruntimeexs-and-mix-appconfig

Given that config/runtime.exs will be loaded at runtime (no restart as with releases.exs) it shouldn’t need to persist anything to disk. Also runtime.exs is not file in your release, which people can look at.

bryanhuntesl

bryanhuntesl OP

I love this community. Yeah, that will do nicely.

Adzz

Adzz

What does confex give you that using releases.exs doesn’t? Or I guess my question is why don’t releases work with a read only file system ?

LostKobrakai

LostKobrakai

Finally, in order for runtime configuration to work properly (as well as any other “Config provider” as defined next), it needs to be able to persist the newly computed configuration to disk. The computed config file will be written to “tmp” directory inside the release every time the system boots.

Edit:
releases.exs works by starting the beam in a minimal setup, apply the releases.exs and write the config back in an erlang config format to disk, stopping and another beam process is then fully starting up using the erlang config written to disk.

josevalim

josevalim

Creator of Elixir

runtime.exs will work the same as releases.exs in the sense that it will also need to write to disk. However, there is a release option on v1.10 that disables the writing to disk:

reboot_system_after_config: false

The nerves team needed this option for similar reasons as @bryanhuntesl, so we added it. The only downside is that you can’t configure kernel/stdlib via config/releases.exs if you use this option. You should still be able to configure them via vm.args though.

LostKobrakai

LostKobrakai

Interesting. This sounds like it’s actually preferable to the default of the rebooting system unless actually needed.

derek-zhou

derek-zhou

Interesting. If I don’t use releases.exs at all, does a release work on a read only file system?

LostKobrakai

LostKobrakai

That should work out of the box. If there’s no runtime config there’s nothing to write.

hauleth

hauleth

Well, there is always possibility to just create tmpfs and mount it where you need write data during startup. In that way you will achieve what you need. IIRC there is possibility to do so automatically with systemd if needed.

bryanhuntesl

bryanhuntesl OP

That sounds a bit complicated for the happy path - a Java, Golang, Ruby application doesn’t need a writable filesystem in order to read it’s configuration at boot.

Where Next?

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91561 914
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
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
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
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
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement