I’m working towards deploying my first Phoenix app to production, and I’m trying to find a good way to add more complex run-time configuration to my app (it’s built with mix release
, so there’s no config.exs
that can be edited on the deployment server).
Environment variables work great for scalar values, but I need an environment-specific structure like this passed into my app
config :app, :dns
servers: [
%{
hostname: "ns1.example.org",
region: "east",
type: :bind
},
%{
hostname: "ns2.example.net",
region: "west",
type: :nsd4
}
]
One approach would be to compile it to JSON and then stuff this JSON into an environment variable, and then read the env-var and parse the JSON in releases.exs
, but that is not exactly elegant. Any suggestions for a better way to accomplish this?