runtime.exs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import Config
  2. alias Config.Helper
  3. # config/runtime.exs is executed for all environments, including
  4. # during releases. It is executed after compilation and before the
  5. # system starts, so it is typically used to load production configuration
  6. # and secrets from environment variables or elsewhere. Do not define
  7. # any compile-time configuration in here, as it won't be applied.
  8. # The block below contains prod specific runtime configuration.
  9. if config_env() == :prod do
  10. env =
  11. Helper.load_all([
  12. {"SECRET_KEY_BASE", "You can generate one by calling: mix phx.gen.secret"},
  13. {"DATABASE_URL", "For example: ecto://USER:PASS@HOST/DATABASE"},
  14. "PORT",
  15. "HOST"
  16. ])
  17. config :toy, ToyWeb.Endpoint,
  18. url: [host: env.host, port: env.port],
  19. http: [
  20. # Enable IPv6 and bind on all interfaces.
  21. # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
  22. # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
  23. # for details about using IPv6 vs IPv4 and loopback vs public addresses.
  24. ip: {0, 0, 0, 0, 0, 0, 0, 0},
  25. port: env.port
  26. ],
  27. secret_key_base: env.secret_key_base,
  28. server: true
  29. # ## Using releases
  30. #
  31. # If you are doing OTP releases, you need to instruct Phoenix
  32. # to start each relevant endpoint:
  33. #
  34. # config :toy, ToyWeb.Endpoint, server: true
  35. #
  36. # Then you can assemble a release by calling `mix release`.
  37. # See `mix help release` for more information.
  38. # ## Configuring the mailer
  39. #
  40. # In production you need to configure the mailer to use a different adapter.
  41. # Also, you may need to configure the Swoosh API client of your choice if you
  42. # are not using SMTP. Here is an example of the configuration:
  43. #
  44. # config :toy, Toy.Mailer,
  45. # adapter: Swoosh.Adapters.Mailgun,
  46. # api_key: System.get_env("MAILGUN_API_KEY"),
  47. # domain: System.get_env("MAILGUN_DOMAIN")
  48. #
  49. # For this example you need include a HTTP client required by Swoosh API client.
  50. # Swoosh supports Hackney and Finch out of the box:
  51. #
  52. # config :swoosh, :api_client, Swoosh.ApiClient.Hackney
  53. #
  54. # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
  55. config :toy, Toy.Repo,
  56. # ssl: true,
  57. url: env.database_url,
  58. pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
  59. end