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
23if config_env() == :prod do
24 database_url =
25 System.get_env("DATABASE_URL") ||
26 raise """
27 environment variable DATABASE_URL is missing.
28 For example: ecto://USER:PASS@HOST/DATABASE
29 """
30
31 maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
32
33 config :comet, Comet.Repo,
34 # ssl: true,
35 url: database_url,
36 pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
37 socket_options: maybe_ipv6
38
39 # The secret key base is used to sign/encrypt cookies and other secrets.
40 # A default value is used in config/dev.exs and config/test.exs but you
41 # want to use a different value for prod and you most likely don't want
42 # to check this value into version control, so we use an environment
43 # variable instead.
44 secret_key_base =
45 System.get_env("SECRET_KEY_BASE") ||
46 raise """
47 environment variable SECRET_KEY_BASE is missing.
48 You can generate one by calling: mix phx.gen.secret
49 """
50
51 host = System.get_env("PHX_HOST") || "example.com"
52 port = String.to_integer(System.get_env("PORT") || "4000")
53
54 config :comet, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
55
56 config :comet, CometWeb.Endpoint,
57 url: [host: host, port: 443, scheme: "https"],
58 http: [
59 # Enable IPv6 and bind on all interfaces.
60 # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
61 # See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
62 # for details about using IPv6 vs IPv4 and loopback vs public addresses.
63 ip: {0, 0, 0, 0, 0, 0, 0, 0},
64 port: port
65 ],
66 secret_key_base: secret_key_base
67
68 # ## SSL Support
69 #
70 # To get SSL working, you will need to add the `https` key
71 # to your endpoint configuration:
72 #
73 # config :comet, CometWeb.Endpoint,
74 # https: [
75 # ...,
76 # port: 443,
77 # cipher_suite: :strong,
78 # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
79 # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
80 # ]
81 #
82 # The `cipher_suite` is set to `:strong` to support only the
83 # latest and more secure SSL ciphers. This means old browsers
84 # and clients may not be supported. You can set it to
85 # `:compatible` for wider support.
86 #
87 # `:keyfile` and `:certfile` expect an absolute path to the key
88 # and cert in disk or a relative path inside priv, for example
89 # "priv/ssl/server.key". For all supported SSL configuration
90 # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
91 #
92 # We also recommend setting `force_ssl` in your config/prod.exs,
93 # ensuring no data is ever sent via http, always redirecting to https:
94 #
95 # config :comet, CometWeb.Endpoint,
96 # force_ssl: [hsts: true]
97 #
98 # Check `Plug.SSL` for all available options in `force_ssl`.
99end