Using Dotenvy in Elixir Releases

import Config
import Dotenvy
source!([
"config/.env",
"config/.#{config_env()}.env",
"config/.#{config_env()}.local.env"
])
config :foo,
goalkeeper: env!("GOALKEEPER", :string),
fullback: env!("FULLBACK", :string),
sweeper: env!("SWEEPER", :string)

Including your .envs inside a release

releases: [
myapp: [
include_executables_for: [:unix],
steps: [:assemble, :tar],
overlays: ["envs/"],
path: "_build/rel"
]
]
# For local development, read env files inside the envs/ dir;
# for releases, read them at the RELEASE_ROOT
config_dir_prefix = System.fetch_env("RELEASE_ROOT")
|> case do
:error -> "envs/"
{:ok, value} ->
IO.puts("Loading dotenv files from #{value}")
"#{value}/"
end
source!([
"#{config_dir_prefix}.env",
"#{config_dir_prefix}.#{config_env()}.env",
"#{config_dir_prefix}.#{config_env()}.local.env"
])
_build/rel/bin/foo start_iexiex> Application.get_env(:foo, :goalkeeper)
"Glorb"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store