From 526ad6eddaee84bc82adacc95c88c6e6f3eb220e Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 6 Mar 2020 14:30:55 +0300 Subject: [PATCH] Env-based configs (#2) --- config/config.exs | 31 +++---------------------------- config/dev.exs | 32 ++++++++++++++++++++++++++++++++ config/prod.exs | 6 ++++++ config/releases.exs | 29 +---------------------------- config/test.exs | 5 +++++ 5 files changed, 47 insertions(+), 56 deletions(-) create mode 100644 config/dev.exs create mode 100644 config/prod.exs create mode 100644 config/test.exs diff --git a/config/config.exs b/config/config.exs index bb6b66c..79a8b3c 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,35 +1,10 @@ import Config -config :pathfinder, Woody.Server, - ip: "0.0.0.0", - port: 8022 +# Common compile-time app env config :pathfinder, ecto_repos: [NewWay.Repo] -config :pathfinder, NewWay.Repo, - database: "nw", - username: "postgres", - password: "postgres", - hostname: "postgres" - -config :pathfinder, :logger, [ - {:handler, :default, :logger_std_h, %{ - :config => %{ - :type => {:file, 'console.json'} - }, - :formatter => {:logger_logstash_formatter, %{ - :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] - }} - }}, - {:handler, Logger, :logger_std_h, %{ - :config => %{ - :type => {:file, 'console.json'} - }, - :formatter => {:logger_logstash_formatter, %{ - :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] - }} - }} -] - # Dont use Elixir's logger config :logger, backends: [] + +import_config("#{Mix.env()}.exs") diff --git a/config/dev.exs b/config/dev.exs new file mode 100644 index 0000000..7db43de --- /dev/null +++ b/config/dev.exs @@ -0,0 +1,32 @@ +import Config + +# Development compile-time app env + +config :pathfinder, Woody.Server, + ip: "0.0.0.0", + port: 8022 + +config :pathfinder, NewWay.Repo, + database: "nw", + username: "postgres", + password: "postgres", + hostname: "postgres" + +config :pathfinder, :logger, [ + {:handler, :default, :logger_std_h, %{ + :config => %{ + :type => {:file, 'console.json'} + }, + :formatter => {:logger_logstash_formatter, %{ + :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] + }} + }}, + {:handler, Logger, :logger_std_h, %{ + :config => %{ + :type => {:file, 'console.json'} + }, + :formatter => {:logger_logstash_formatter, %{ + :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] + }} + }} +] diff --git a/config/prod.exs b/config/prod.exs new file mode 100644 index 0000000..072c971 --- /dev/null +++ b/config/prod.exs @@ -0,0 +1,6 @@ +import Config + +# Production compile-time app env + +config :pathfinder, NewWay.Repo, + show_sensitive_data_on_connection_error: :false diff --git a/config/releases.exs b/config/releases.exs index e4c75e3..07e1cae 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -1,30 +1,3 @@ import Config -config :pathfinder, Woody.Server, - ip: "0.0.0.0", - port: 8022 - -config :pathfinder, NewWay.Repo, - database: "nw", - username: "postgres", - password: "postgres", - hostname: "postgres" - -config :pathfinder, :logger, [ - {:handler, :default, :logger_std_h, %{ - :config => %{ - :type => {:file, 'console.json'} - }, - :formatter => {:logger_logstash_formatter, %{ - :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] - }} - }}, - {:handler, Logger, :logger_std_h, %{ - :config => %{ - :type => {:file, 'console.json'} - }, - :formatter => {:logger_logstash_formatter, %{ - :exclude_meta_fields => [:ansi_color, :application, :file, :line, :mfa, :pid, :gl, :domain] - }} - }} -] +# Configure release environment here diff --git a/config/test.exs b/config/test.exs new file mode 100644 index 0000000..583f30f --- /dev/null +++ b/config/test.exs @@ -0,0 +1,5 @@ +import Config + +# Test compile-time app env + +import_config("dev.exs")