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