runtime.exs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Config
  2. # config/runtime.exs is executed for all environments, including
  3. # during releases. It is executed after compilation and before the
  4. # system starts, so it typically used load production configuration
  5. # and secrets from environment variables or elsewhere. Do not define
  6. # any compile-time configuration in here, as it won't be applied.
  7. # The block below contains prod specific runtime configuration.
  8. if config_env() == :prod do
  9. secret_key_base =
  10. System.get_env("SECRET_KEY_BASE") ||
  11. raise """
  12. environment variable SECRET_KEY_BASE is missing.
  13. You can generate one by calling: mix phx.gen.secret
  14. """
  15. database_url =
  16. System.get_env("DATABASE_URL") ||
  17. raise """
  18. environment variable DATABASE_URL is missing.
  19. For example: ecto://USER:PASS@HOST/DATABASE
  20. """
  21. port =
  22. System.get_env("PORT") ||
  23. raise "environment variable PORT is missing."
  24. host =
  25. System.get_env("HOST") ||
  26. raise "environment variable HOST is missing."
  27. config :toy, ToyWeb.Endpoint,
  28. url: [host: host, port: port],
  29. http: [
  30. # Enable IPv6 and bind on all interfaces.
  31. # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
  32. # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
  33. # for details about using IPv6 vs IPv4 and loopback vs public addresses.
  34. ip: {0, 0, 0, 0, 0, 0, 0, 0},
  35. port: port
  36. ],
  37. secret_key_base: secret_key_base
  38. config :toy, Toy.Repo,
  39. # ssl: true,
  40. url: database_url,
  41. pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
  42. # ## Using releases
  43. #
  44. # If you are doing OTP releases, you need to instruct Phoenix
  45. # to start each relevant endpoint:
  46. #
  47. # config :<%= @web_app_name %>, <%= @endpoint_module %>, server: true
  48. #
  49. # Then you can assemble a release by calling `mix release`.
  50. # See `mix help release` for more information.
  51. end