runtime.exs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. config :toy, ToyWeb.Endpoint,
  22. http: [
  23. # Enable IPv6 and bind on all interfaces.
  24. # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
  25. # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
  26. # for details about using IPv6 vs IPv4 and loopback vs public addresses.
  27. ip: {0, 0, 0, 0, 0, 0, 0, 0},
  28. port: String.to_integer(System.get_env("PORT") || "4000")
  29. ],
  30. secret_key_base: secret_key_base
  31. config :toy, Toy.Repo,
  32. # ssl: true,
  33. url: database_url,
  34. pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
  35. # ## Using releases
  36. #
  37. # If you are doing OTP releases, you need to instruct Phoenix
  38. # to start each relevant endpoint:
  39. #
  40. # config :<%= @web_app_name %>, <%= @endpoint_module %>, server: true
  41. #
  42. # Then you can assemble a release by calling `mix release`.
  43. # See `mix help release` for more information.
  44. end