A config provider to read TOML configuration files that works with Elixir (1.9+) releases.
Note: If you are building releases with Distillery, you can use the config provider from the toml-elixir library.
- Elixir >= 1.9
The package can be installed by adding toml_config
to your list of
dependencies in mix.exs
:
def deps do
[
{:toml_config, "~> 0.1", only: :prod}
]
end
Update the release configuration in your mix.exs file:
You can either give a fully qualified pathname to the config file.
releases: [
my_app: [
config_providers: [
{TomlConfigProvider, path: "/absolute/path/to/my/config.toml"}
],
...
]
]
Or you can read the config directory or path from a specified environment variable. Booting the application fails if the specified environment variable is undefined.
releases: [
my_app: [
config_providers: [
{TomlConfigProvider,
path: {:system, "RELEASE_CONFIG_DIR", "my_app.toml"}}
],
...
]
]
Or:
releases: [
my_app: [
config_providers: [
{TomlConfigProvider, path: {:system, "RELEASE_CONFIG_PATH"}}
],
...
]
]
All config provider options except :path
are forwarded to Toml.decode_file/2
from the toml-elixir library. Thus,
you can also provide custom transforms.
config_providers: [
{TomlConfigProvider,
path: "path/to/my/config.toml",
transforms: [UrlTransform, TupleTransform]}
]
The toml package brings it's own config provider that unfortunately only works with distellery releases at the moment.
Unlike toml_config_provider, this library allows specifying the location of the config file through environment variables. This is quite useful when you have multiple (slightly different) instances of a release running on the same machine, such as staging and production environments. Additionally, we allow custom transform modules.
Documentation can be generated with ExDoc and is published on HexDocs.