-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move config in prod.exs to runtime.exs #94
- Loading branch information
Showing
3 changed files
with
77 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,6 @@ | ||
use Mix.Config | ||
|
||
# For production, we configure the host to read the PORT | ||
# from the system environment. Therefore, you will need | ||
# to set PORT=80 before running your server. | ||
# | ||
# You should also configure the url host to something | ||
# meaningful, we use this information when generating URLs. | ||
# | ||
# Finally, we also include the path to a manifest | ||
# containing the digested version of static files. This | ||
# manifest is generated by the mix phoenix.digest task | ||
# which you typically run after static files are built. | ||
config :magpie, Magpie.Endpoint, | ||
load_from_system_env: true, | ||
http: [port: {:system, "PORT"}], | ||
# Replace the host with your own application URL! | ||
url: [scheme: "https", host: "${APP_NAME}.gigalixirapp.com", port: 443], | ||
force_ssl: [rewrite_on: [:x_forwarded_proto]], | ||
cache_static_manifest: "priv/static/cache_manifest.json", | ||
# Configuration for Heroku | ||
secret_key_base: "${SECRET_KEY_BASE}", | ||
# Needed for Distillery releases | ||
server: true, | ||
# Allow clients from anywhere to connect to use the interactive experiment facilities. We can't constrain where the user chooses to host the frontend anyways. | ||
check_origin: false, | ||
root: ".", | ||
version: Application.spec(:magpie, :vsn) | ||
|
||
# Configure the database | ||
config :magpie, Magpie.Repo, | ||
adapter: Ecto.Adapters.Postgres, | ||
url: "${DATABASE_URL}", | ||
database: "", | ||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "2"), | ||
ssl: true, | ||
log: | ||
(if System.get_env("USE_TIMBER") == "true" do | ||
false | ||
else | ||
:debug | ||
end) | ||
|
||
config :logger, | ||
level: :info, | ||
backends: | ||
(if System.get_env("USE_TIMBER") == "true" do | ||
[Timber.LoggerBackends.HTTP, :console] | ||
else | ||
[:console] | ||
end) | ||
|
||
config :timber, | ||
api_key: "${TIMBER_API_KEY}", | ||
source_id: "${TIMBER_SOURCE_ID}" | ||
|
||
# Used for basic_auth | ||
config :magpie, :authentication, | ||
username: "${AUTH_USERNAME}", | ||
password: "${AUTH_PASSWORD}" | ||
|
||
config :magpie, :environment, :prod | ||
|
||
# This is useful when the app is behind a reverse proxy and you need to actually use the URL shown to the outside by the reverse proxy, e.g. in template generation in web/templates/experiments/edit.html..ex | ||
# config :magpie, :real_url, "URL_PRESENTED_BY_REVERSE_PROXY" | ||
|
||
# ## SSL Support | ||
# | ||
# To get SSL working, you will need to add the `https` key | ||
# to the previous section and set your `:url` port to 443: | ||
# | ||
# config :magpie, Magpie.Endpoint, | ||
# ... | ||
# url: [host: "example.com", port: 443], | ||
# https: [port: 443, | ||
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), | ||
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")] | ||
# | ||
# Where those two env variables return an absolute path to | ||
# the key and cert in disk or a relative path inside priv, | ||
# for example "priv/ssl/server.key". | ||
# | ||
# We also recommend setting `force_ssl`, ensuring no data is | ||
# ever sent via http, always redirecting to https: | ||
# | ||
# config :magpie, Magpie.Endpoint, | ||
# force_ssl: [hsts: true] | ||
# | ||
# Check `Plug.SSL` for all available options in `force_ssl`. | ||
|
||
# ## Using releases | ||
# | ||
# If you are doing OTP releases, you need to instruct Phoenix | ||
# to start the server for all endpoints: | ||
# | ||
# config :phoenix, :serve_endpoints, true | ||
# | ||
# Alternatively, you can configure exactly which server to | ||
# start per endpoint: | ||
# | ||
# config :magpie, Magpie.Endpoint, server: true | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Config | ||
|
||
config :magpie, Magpie.Endpoint, | ||
http: [port: System.fetch_env!("PORT") |> String.to_integer()], | ||
url: [ | ||
scheme: System.fetch_env!("URL_SCHEME"), | ||
host: System.fetch_env!("HOST"), | ||
path: System.fetch_env!("PATH"), | ||
port: System.fetch_env!("PORT") |> String.to_integer() | ||
], | ||
force_ssl: | ||
(if System.fetch_env!("URL_SCHEME") == "https" do | ||
[rewrite_on: [:x_forwarded_proto]] | ||
else | ||
[] | ||
end), | ||
server: true, | ||
# Allow clients from anywhere to connect to use the interactive experiment facilities. We can't constrain where the user chooses to host the frontend anyways. | ||
secret_key_base: System.fetch_env!("SECRET_KEY_BASE"), | ||
check_origin: false, | ||
root: ".", | ||
version: Application.spec(:magpie, :vsn), | ||
instrumenters: | ||
(if System.get_env("USE_TIMBER") == "true" do | ||
[Timber.Phoenix] | ||
else | ||
[] | ||
end) | ||
|
||
# Configure the database | ||
config :magpie, Magpie.Repo, | ||
adapter: Ecto.Adapters.Postgres, | ||
username: System.fetch_env!("DATABASE_USERNAME"), | ||
password: System.fetch_env!("DATABASE_PASSWORD"), | ||
hostname: System.fetch_env!("DATABASE_HOST"), | ||
database: System.fetch_env!("DATABASE_NAME"), | ||
pool_size: String.to_integer(System.get_env("POOL_SIZE", "2")), | ||
ssl: true, | ||
log: | ||
(if System.get_env("USE_TIMBER") == "true" do | ||
false | ||
else | ||
:debug | ||
end) | ||
|
||
# Used for basic_auth | ||
config :magpie, :authentication, | ||
username: System.fetch_env!("AUTH_USERNAME"), | ||
password: System.fetch_env!("AUTH_PASSWORD") | ||
|
||
# We don't have a basic auth on the demo app | ||
config :magpie, | ||
:no_basic_auth, | ||
(if System.get_env("MAGPIE_NO_BASIC_AUTH") == "true" do | ||
true | ||
else | ||
false | ||
end) | ||
|
||
config :logger, | ||
backends: | ||
(if System.get_env("USE_TIMBER") == "true" do | ||
[Timber.LoggerBackends.HTTP, :console] | ||
else | ||
[:console] | ||
end) | ||
|
||
# Logging | ||
config :timber, | ||
api_key: System.get_env("TIMBER_API_KEY"), | ||
source_id: System.get_env("TIMBER_SOURCE_ID") | ||
|
||
# This is useful when the app is behind a reverse proxy and you need to actually use the URL shown to the outside by the reverse proxy, e.g. in template generation in web/templates/experiments/edit.html..ex | ||
config :magpie, :real_url, System.get_env("REAL_URL", System.fetch_env!("HOST")) |