### CONFIG.EXS
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.

# General application configuration
use Mix.Config

config :home_dash,
  ecto_repos: [HomeDash.Repo]

# Configures the endpoint
config :home_dash, HomeDashWeb.Endpoint,
  url: [host: "localhost"],
  secret_key_base: "7qbmSECQ8DXTdIogzUyE7cWkfkYDfYlXn4cYuEjW8owJNza3XDsc9Dii6OS3PZh/",
  render_errors: [view: HomeDashWeb.ErrorView, accepts: ~w(html json)],
  pubsub: [name: HomeDash.PubSub, adapter: Phoenix.PubSub.PG2],
  live_view: [signing_salt: "R/RRcygN"]

# Add support for microseconds at the database level
# avoid having to configure it on every migration file
config :home_dash, HomeDash.Repo, migration_timestamps: [type: :utc_datetime_usec]

# Configures Elixir's Logger
config :logger, :console,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"



###PROD.EXS

use Mix.Config

# For production, don't forget to configure the url host
# to something meaningful, Phoenix uses this information
# when generating URLs.
#
# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :home_dash, HomeDashWeb.Endpoint,
  cache_static_manifest: "priv/static/cache_manifest.json"

# Do not print debug messages in production
config :logger, level: :debug

# config :home_dash, HomeDashWeb.Endpoint, server: true




#### RELEASES.EXS
import Config

################################################################################
# Database #####################################################################
################################################################################

db_host =
  System.get_env("DATABASE_HOST") ||
    raise """
    environment variable DATABASE_HOST is missing.
    """

db_database = System.get_env("DATABASE_DB") || "homedashdb"
db_username = System.get_env("DATABASE_USER") || "homedash"
db_password = System.get_env("DATABASE_PASSWORD") || "homedash"
db_url = "ecto://#{db_username}:#{db_password}@#{db_host}/#{db_database}"

config :home_dash, HomeDash.Repo,
  url: db_url,
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

################################################################################
# Secrets ######################################################################
################################################################################

secret_key_base =
  System.get_env("SECRET_KEY_BASE") ||
    raise """
    environment variable SECRET_KEY_BASE is missing.
    You can generate one by calling: mix phx.gen.secret
    """

config :home_dash, MyAppWeb.Endpoint,
  http: [port: 4000],
  check_origin: false,
  secret_key_base: secret_key_base