1import Config
2
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
10# ## Using releases
11#
12# If you use `mix release`, you need to explicitly enable the server
13# by passing the PHX_SERVER=true when you start it:
14#
15# PHX_SERVER=true bin/comet start
16#
17# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
18# script that automatically sets the env var above.
19if System.get_env("PHX_SERVER") do
20 config :comet, CometWeb.Endpoint, server: true
21end
22
23config :comet, CometWeb.Endpoint, http: [port: String.to_integer(System.get_env("PORT", "4000"))]
24
25if config_env() == :prod do
26 database_url =
27 System.get_env("DATABASE_URL") ||
28 raise """
29 environment variable DATABASE_URL is missing.
30 For example: ecto://USER:PASS@HOST/DATABASE
31 """
32
33 maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
34
35 config :comet, Comet.Repo,
36 # ssl: true,
37 url: database_url,
38 pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
39 # For machines with several cores, consider starting multiple pools of `pool_size`
40 # pool_count: 4,
41 socket_options: maybe_ipv6
42
43 # The secret key base is used to sign/encrypt cookies and other secrets.
44 # A default value is used in config/dev.exs and config/test.exs but you
45 # want to use a different value for prod and you most likely don't want
46 # to check this value into version control, so we use an environment
47 # variable instead.
48 secret_key_base =
49 System.get_env("SECRET_KEY_BASE") ||
50 raise """
51 environment variable SECRET_KEY_BASE is missing.
52 You can generate one by calling: mix phx.gen.secret
53 """
54
55 host = System.get_env("PHX_HOST") || "example.com"
56
57 config :comet, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
58
59 config :comet, CometWeb.Endpoint,
60 url: [host: host, port: 443, scheme: "https"],
61 http: [
62 # Enable IPv6 and bind on all interfaces.
63 # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
64 # See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
65 # for details about using IPv6 vs IPv4 and loopback vs public addresses.
66 ip: {0, 0, 0, 0, 0, 0, 0, 0}
67 ],
68 secret_key_base: secret_key_base
69
70 # ## SSL Support
71 #
72 # To get SSL working, you will need to add the `https` key
73 # to your endpoint configuration:
74 #
75 # config :comet, CometWeb.Endpoint,
76 # https: [
77 # ...,
78 # port: 443,
79 # cipher_suite: :strong,
80 # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
81 # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
82 # ]
83 #
84 # The `cipher_suite` is set to `:strong` to support only the
85 # latest and more secure SSL ciphers. This means old browsers
86 # and clients may not be supported. You can set it to
87 # `:compatible` for wider support.
88 #
89 # `:keyfile` and `:certfile` expect an absolute path to the key
90 # and cert in disk or a relative path inside priv, for example
91 # "priv/ssl/server.key". For all supported SSL configuration
92 # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
93 #
94 # We also recommend setting `force_ssl` in your config/prod.exs,
95 # ensuring no data is ever sent via http, always redirecting to https:
96 #
97 # config :comet, CometWeb.Endpoint,
98 # force_ssl: [hsts: true]
99 #
100 # Check `Plug.SSL` for all available options in `force_ssl`.
101
102 # ## Configuring the mailer
103 #
104 # In production you need to configure the mailer to use a different adapter.
105 # Here is an example configuration for Mailgun:
106 #
107 # config :comet, Comet.Mailer,
108 # adapter: Swoosh.Adapters.Mailgun,
109 # api_key: System.get_env("MAILGUN_API_KEY"),
110 # domain: System.get_env("MAILGUN_DOMAIN")
111 #
112 # Most non-SMTP adapters require an API client. Swoosh supports Req, Hackney,
113 # and Finch out-of-the-box. This configuration is typically done at
114 # compile-time in your config/prod.exs:
115 #
116 # config :swoosh, :api_client, Swoosh.ApiClient.Req
117 #
118 # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
119end