|
|
@@ -1,4 +1,5 @@
|
|
|
import Config
|
|
|
+alias Config.Helper
|
|
|
|
|
|
# config/runtime.exs is executed for all environments, including
|
|
|
# during releases. It is executed after compilation and before the
|
|
|
@@ -7,43 +8,29 @@ import Config
|
|
|
# any compile-time configuration in here, as it won't be applied.
|
|
|
# The block below contains prod specific runtime configuration.
|
|
|
if config_env() == :prod do
|
|
|
- secret_key_base =
|
|
|
- System.get_env("SECRET_KEY_BASE") ||
|
|
|
- raise """
|
|
|
- environment variable SECRET_KEY_BASE is missing.
|
|
|
- You can generate one by calling: mix phx.gen.secret
|
|
|
- """
|
|
|
-
|
|
|
- database_url =
|
|
|
- System.get_env("DATABASE_URL") ||
|
|
|
- raise """
|
|
|
- environment variable DATABASE_URL is missing.
|
|
|
- For example: ecto://USER:PASS@HOST/DATABASE
|
|
|
- """
|
|
|
-
|
|
|
- port =
|
|
|
- System.get_env("PORT") ||
|
|
|
- raise "environment variable PORT is missing."
|
|
|
-
|
|
|
- host =
|
|
|
- System.get_env("HOST") ||
|
|
|
- raise "environment variable HOST is missing."
|
|
|
+ env =
|
|
|
+ Helper.load_all([
|
|
|
+ {"SECRET_KEY_BASE", "You can generate one by calling: mix phx.gen.secret"},
|
|
|
+ {"DATABASE_URL", "For example: ecto://USER:PASS@HOST/DATABASE"},
|
|
|
+ "PORT",
|
|
|
+ "HOST"
|
|
|
+ ])
|
|
|
|
|
|
config :toy, ToyWeb.Endpoint,
|
|
|
- url: [host: host, port: port],
|
|
|
+ url: [host: env.host, port: env.port],
|
|
|
http: [
|
|
|
# Enable IPv6 and bind on all interfaces.
|
|
|
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
|
|
|
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
|
|
|
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
|
|
|
ip: {0, 0, 0, 0, 0, 0, 0, 0},
|
|
|
- port: port
|
|
|
+ port: env.port
|
|
|
],
|
|
|
- secret_key_base: secret_key_base
|
|
|
+ secret_key_base: env.secret_key_base
|
|
|
|
|
|
config :toy, Toy.Repo,
|
|
|
# ssl: true,
|
|
|
- url: database_url,
|
|
|
+ url: env.database_url,
|
|
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
|
|
|
|
|
# ## Using releases
|