Hi all! I haven’t worked with Elixir since v1.7. I was just checking out the new mix release functionality and I was thinking about how I used to work with environment variables before.
Is there a way with the new mix release process to read environment variables at runtime? Or do they still have to be populated when compiling the release? For example, I want to compile a release tarball, then send it to my remote server, then run it with a specific port specified at runtime with an environment variable.
@LostKobrakai@hauleth Thanks! I don’t see anything in that documentation about using environment variables, but I do see the config providers structure.
Would you recommend that I basically just implement a simple config provider which reads from environment variables using System.fetch_env(varname) to do so?
According to this part of the docs the config/releases.exs will be evaluated on each start of the release, which mean you can use System.fetch_env/1 there and it will work as expected.
Wow that is awesome! Definitely saving this article. I use Docker to setup automatic deployments on my CI so this is going to be perfect. I have an old app setup using Distillery but I’ve been excited to get back into it and set it up with the new Mix release method.