GamendWeb.HostRuntime (gamend_web v1.0.1215)

Copy Markdown View Source

The boot-time configuration derivations every host shares: declared settings turned into the shapes Phoenix, Ecto, Bandit, Swoosh and Pigeon expect.

This used to live only in this repo's config/host_runtime.exs, which host repos forked and let drift — one fork went 361 lines out of sync, another slimmed itself down to just the Settings.from_env/0 loop and lost the Repo and Endpoint configuration entirely. Shipping the derivations as code means a host's config/host_runtime.exs is one loop:

for entry <-
      GamendWeb.HostRuntime.config(config_env(),
        host_root: Path.expand("..", __DIR__)
      ) do
  case entry do
    {app, opts} -> config app, opts
    {app, key, value} -> config app, key, value
  end
end

Gamend.Settings.from_env/0 is folded in, so the loop above is the entire settings layer; hosts add genuinely host-specific config after it.

host_root anchors the host-relative defaults (db/, data/). Entries are {app, opts} for config/2 and {app, key, value} for config/3, in the order they must be applied.

Summary

Types

entry()

@type entry() :: {atom(), keyword()} | {atom(), term(), term()}

Functions

config(env, opts \\ [])

@spec config(:dev | :test | :prod, keyword()) :: [entry()]