Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Interpolating environment variables

Let's start by looking at the way we set the database configuration in the elixir_drip umbrella app while developing locally:

$ cat apps/elixir_drip/config/dev.exsuse Mix.Configconfig :elixir_drip, ElixirDrip.Repo,  adapter: Ecto.Adapters.Postgres,  username: System.get_env("DB_USER"),  password: System.get_env("DB_PASS"),  database: System.get_env("DB_NAME"),  hostname: System.get_env("DB_HOST"),  port: System.get_env("DB_PORT"),  pool_size: 10

All these Mix configuration entries are evaluated at runtime, so when we run the application with mix or mix phx.server, we know all those entries will be set according to the existing DB_* environment variables. If one of those environment variables doesn't exist, Mix ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content