109 lines
3.8 kB
1
import 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/blog 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.
19
if System.get_env("PHX_SERVER") do
20
config :blog, BlogWeb.Endpoint, server: true
21
end
22
23
if config_env() == :prod do
24
secret_key_base =
25
System.get_env("SECRET_KEY_BASE") ||
26
raise """
27
environment variable SECRET_KEY_BASE is missing.
28
You can generate one by calling: mix phx.gen.secret
29
"""
30
31
host = System.get_env("PHX_HOST") || "example.com"
32
port = String.to_integer(System.get_env("PORT") || "4000")
33
34
config :blog, BlogWeb.Endpoint,
35
url: [host: host, port: 443, scheme: "https"],
36
http: [
37
ip: {0, 0, 0, 0, 0, 0, 0, 0},
38
port: port
39
],
40
secret_key_base: secret_key_base
41
42
# ## SSL Support
43
#
44
# To get SSL working, you will need to add the `https` key
45
# to your endpoint configuration:
46
#
47
# config :blog, BlogWeb.Endpoint,
48
# https: [
49
# ...,
50
# port: 443,
51
# cipher_suite: :strong,
52
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
53
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
54
# ]
55
#
56
# The `cipher_suite` is set to `:strong` to support only the
57
# latest and more secure SSL ciphers. This means old browsers
58
# and clients may not be supported. You can set it to
59
# `:compatible` for wider support.
60
#
61
# `:keyfile` and `:certfile` expect an absolute path to the key
62
# and cert in disk or a relative path inside priv, for example
63
# "priv/ssl/server.key". For all supported SSL configuration
64
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
65
#
66
# We also recommend setting `force_ssl` in your config/prod.exs,
67
# ensuring no data is ever sent via http, always redirecting to https:
68
#
69
# config :blog, BlogWeb.Endpoint,
70
# force_ssl: [hsts: true]
71
#
72
# Check `Plug.SSL` for all available options in `force_ssl`.
73
74
# ## Configuring the mailer
75
#
76
# In production you need to configure the mailer to use a different adapter.
77
# Also, you may need to configure the Swoosh API client of your choice if you
78
# are not using SMTP. Here is an example of the configuration:
79
#
80
# config :blog, Blog.Mailer,
81
# adapter: Swoosh.Adapters.Mailgun,
82
# api_key: System.get_env("MAILGUN_API_KEY"),
83
# domain: System.get_env("MAILGUN_DOMAIN")
84
#
85
# For this example you need include a HTTP client required by Swoosh API client.
86
# Swoosh supports Hackney and Finch out of the box:
87
#
88
# config :swoosh, :api_client, Swoosh.ApiClient.Hackney
89
#
90
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
91
92
config :blog, :nats,
93
host: System.get_env("NATS_HOST", "localhost"),
94
port: String.to_integer(System.get_env("NATS_PORT", "4222"))
95
96
database_url =
97
System.get_env("DATABASE_URL") ||
98
raise """
99
environment variable DATABASE_URL is missing.
100
For example: ecto://USER:PASS@HOST/DATABASE
101
"""
102
103
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
104
105
config :blog, Blog.Repo,
106
url: database_url,
107
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
108
socket_options: maybe_ipv6
109
end
110