jswny
New mix releases environment variables at runtime
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.
Thanks!
Marked As Solved
hauleth
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.
Also Liked
LostKobrakai
config/releases.exs is evaluated on startup of the release.
akoutmos
If you are looking for a tutorial style application that leverages Mix releases, I put something together on my blog using Docker: Multi-stage Docker Builds and Elixir 1.9 Releases-Alex Koutmos | Engineering Blog
Step 2 is where I go over using a release.ex file. Hopefully that helps guide you in the right direction.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








