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/pipa 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 :pipa, PipaWeb.Endpoint, server: true
21
end
22
23
config :pipa, :timezone, System.get_env("TZ") || "Australia/Melbourne"
24
config :pipa, Pipa.External.Gitlab, System.get_env("GITLAB_TOKEN")
25
config :pipa, Pipa.External.Github, System.get_env("GITHUB_TOKEN")
26
27
if config_env() == :prod do
28
config :pipa, Pipa.Repo,
29
database:
30
System.get_env("DATABASE_PATH") ||
31
raise("""
32
environment variable DATABASE_PATH is missing.
33
""")
34
35
config :pipa, PipaApi,
36
key:
37
System.get_env("PIPA_API_KEY") ||
38
raise("""
39
environment variable PIPA_API_KEY is missing.
40
""")
41
42
config :pipa,
43
:uploads_directory,
44
System.get_env("PIPA_UPLOADS_DIRECTORY") ||
45
raise("""
46
environment variable PIPA_UPLOADS_DIRECTORY is missing.
47
""")
48
49
# The secret key base is used to sign/encrypt cookies and other secrets.
50
# A default value is used in config/dev.exs and config/test.exs but you
51
# want to use a different value for prod and you most likely don't want
52
# to check this value into version control, so we use an environment
53
# variable instead.
54
secret_key_base =
55
System.get_env("SECRET_KEY_BASE") ||
56
raise """
57
environment variable SECRET_KEY_BASE is missing.
58
You can generate one by calling: mix phx.gen.secret
59
"""
60
61
host = System.get_env("PHX_HOST") || "example.com"
62
63
{:ok, ip} =
64
(System.get_env("ADDRESS") || "0.0.0.0") |> String.to_charlist() |> :inet.parse_address()
65
66
port = String.to_integer(System.get_env("PORT") || "4000")
67
68
config :pipa, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
69
70
config :pipa, PipaWeb.Endpoint,
71
url: [host: host, port: port, scheme: "http"],
72
http: [
73
ip: ip,
74
port: port
75
],
76
secret_key_base: secret_key_base
77
78
# ## SSL Support
79
#
80
# To get SSL working, you will need to add the `https` key
81
# to your endpoint configuration:
82
#
83
# config :pipa, PipaWeb.Endpoint,
84
# https: [
85
# ...,
86
# port: 443,
87
# cipher_suite: :strong,
88
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
89
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
90
# ]
91
#
92
# The `cipher_suite` is set to `:strong` to support only the
93
# latest and more secure SSL ciphers. This means old browsers
94
# and clients may not be supported. You can set it to
95
# `:compatible` for wider support.
96
#
97
# `:keyfile` and `:certfile` expect an absolute path to the key
98
# and cert in disk or a relative path inside priv, for example
99
# "priv/ssl/server.key". For all supported SSL configuration
100
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
101
#
102
# We also recommend setting `force_ssl` in your config/prod.exs,
103
# ensuring no data is ever sent via http, always redirecting to https:
104
#
105
# config :pipa, PipaWeb.Endpoint,
106
# force_ssl: [hsts: true]
107
#
108
# Check `Plug.SSL` for all available options in `force_ssl`.
109
110
# ## Configuring the mailer
111
#
112
# In production you need to configure the mailer to use a different adapter.
113
# Here is an example configuration for Mailgun:
114
#
115
# config :pipa, Pipa.Mailer,
116
# adapter: Swoosh.Adapters.Mailgun,
117
# api_key: System.get_env("MAILGUN_API_KEY"),
118
# domain: System.get_env("MAILGUN_DOMAIN")
119
#
120
# Most non-SMTP adapters require an API client. Swoosh supports Req, Hackney,
121
# and Finch out-of-the-box. This configuration is typically done at
122
# compile-time in your config/prod.exs:
123
#
124
# config :swoosh, :api_client, Swoosh.ApiClient.Req
125
#
126
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
127
end
128