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 :remote_retro, RemoteRetroWeb.Endpoint,
  server: true,
  http: [port: {:system, "PORT"}],
  url: [scheme: "https", host: "${HOST}", port: 443],
  static_url: [scheme: "https", host: "${CLOUDFRONT_DOMAIN}", port: 443],
  force_ssl: [rewrite_on: [:x_forwarded_proto], hsts: true],
  cache_static_manifest: "priv/static/cache_manifest.json",
  cache_manifest_skip_vsn: true, # https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-runtime-configuration
  secret_key_base: "${SECRET_KEY_BASE}",
  live_view: [signing_salt: "${SIGNING_SALT}"],
  root: ".",
  version: Keyword.get(Mix.Project.config(), :version)

config :remote_retro, RemoteRetro.Repo,
  url: "${DATABASE_URL}",
  pool_size: 24,
  ssl: true

config :remote_retro,
  canonical_host: System.get_env("HOST")

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

config :remote_retro, :oauth_client, OAuth2.Client
config :remote_retro, :source_version, "${SOURCE_VERSION}"

# DANGER: if someone tries to change this line, they're up to no good.
config :remote_retro, :auth_controller, RemoteRetroWeb.AuthController

# DANGER: if someone tries to change this line, they're up to no good.
config :remote_retro, :allow_user_masquerade, false

config :remote_retro, :extra_headers, "SameSite=None"

config :remote_retro, live_dashboard_repos: [RemoteRetro.Repo]

config :phoenix, static_compressors: [
  PhoenixBakery.Gzip,
  PhoenixBakery.Brotli,
]

config :honeybadger,
  api_key: "${HONEYBADGER_API_KEY}",
  hostname: "${HOST}",
  environment_name: :production,
  project_root: "${HOST}",
  revision: "${SOURCE_VERSION}"

config :remote_retro,
  datadog_client_token: "${DATADOG_CLIENT_TOKEN}",
  datadog_application_id: "${DATADOG_APPLICATION_ID}"

config :remote_retro,
  google_analytics_id: "${GOOGLE_ANALYTICS_ID}"

config :libcluster,
  topologies: [
    k8s_example: [
      strategy: Cluster.Strategy.Kubernetes,
      config: [
        kubernetes_selector: "${LIBCLUSTER_KUBERNETES_SELECTOR}",
        kubernetes_node_basename: "${LIBCLUSTER_KUBERNETES_NODE_BASENAME}"
      ]
    ]
  ]

# ## 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 :remote_retro, RemoteRetroWeb.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 :remote_retro, RemoteRetroWeb.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 :remote_retro, RemoteRetroWeb.Endpoint, server: true
#
