martinos
Elixir 1.9 runtime config for multiple app name
I have an application that needs to run under 2 different name/configuration on the same box. I have read the mix release documentation but I can’t figure out how I can do this. For dynamic configuration, it says that I need to create a config/releases.exs file as such:
import Config
config :my_app, :secret_key, System.fetch_env!("MY_APP_SECRET_KEY")
However I have some config value that I cannot be put in an environment variable, is there a way to have a config.exs file per application name on the target machine ?
Here’s my mix.exs project section.
def project do
[
app: :my_app,
version: "0.1.0",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps(),
releases: [
as: [
include_executables_for: [:unix],
applications: [runtime_tools: :permanent]
],
vs: [
include_executables_for: [:unix],
applications: [runtime_tools: :permanent]
]
]
]
end
I would like to have different runtime config for the as and vs app names.
Marked As Solved
josevalim
Because the config script is regular Elixir code, you can have the config/releases.exs execute another config file (or load any other file) that your devops/admin team will change.
For example:
release_root = System.fetch_env!("RELEASE_ROOT")
for {application, kv} <- Config.Reader.read!(Path.join(release_root, "config.exs")),
{key, value} <- kv do
config application, key, value
end
Also Liked
josevalim
You can use runtime_config_path (mentioned in the docs here). You can also access all environment variables, include RELEASE_NAME, inside the script itself: https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-environment-variables








