From d6e877137f2a8822c2e98b6a8140369acdbc7ca3 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 24 Aug 2019 15:19:11 +0200 Subject: [PATCH] Remove config in UI. Merge dev config in UI into firmware config. --- firmware/config/config.exs | 15 +++------ firmware/config/host.exs | 40 +++++++++++++++++++++++ firmware/config/target.exs | 14 +++++++- ui/config/config.exs | 29 ----------------- ui/config/dev.exs | 67 -------------------------------------- ui/config/prod.exs | 55 ------------------------------- ui/config/prod.secret.exs | 26 --------------- ui/config/test.exs | 10 ------ 8 files changed, 57 insertions(+), 199 deletions(-) create mode 100644 firmware/config/host.exs delete mode 100644 ui/config/config.exs delete mode 100644 ui/config/dev.exs delete mode 100644 ui/config/prod.exs delete mode 100644 ui/config/prod.secret.exs delete mode 100644 ui/config/test.exs diff --git a/firmware/config/config.exs b/firmware/config/config.exs index 1ad0366..82b9a63 100644 --- a/firmware/config/config.exs +++ b/firmware/config/config.exs @@ -26,18 +26,11 @@ config :shoehorn, config :logger, backends: [RingLogger] -config :ui, UiWeb.Endpoint, - url: [host: "www.geokunis2.nl"], - http: [port: 80], - secret_key_base: "HEY05EB1dFVSu6KykKHuS4rQPQzSHv4F7mGVB/gnDLrIu75wE/ytBXy2TaL3A6RA", - root: Path.dirname(__DIR__), - server: true, - render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)], - pubsub: [name: Nerves.PubSub, adapter: Phoenix.PubSub.PG2], - code_reloader: false - config :phoenix, :json_library, Jason if Mix.target() != :host do - import_config "target.exs" + "target.exs" +else + "host.exs" end +|> import_config() diff --git a/firmware/config/host.exs b/firmware/config/host.exs new file mode 100644 index 0000000..76bc675 --- /dev/null +++ b/firmware/config/host.exs @@ -0,0 +1,40 @@ +use Mix.Config + +config :ui, UiWeb.Endpoint, + url: [host: "localhost"], + secret_key_base: "FkfuB09FEncz4aAi6hS6w5bsNast+D1P12MckXr5dlRdhtFJrKqgEhvhpTU3qzgh", + render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)], + pubsub: [name: Ui.PubSub, adapter: Phoenix.PubSub.PG2], + http: [port: 4000], + server: true, + debug_errors: true, + code_reloader: true, + check_origin: false, + watchers: [ + node: [ + "node_modules/webpack/bin/webpack.js", + "--mode", + "development", + "--watch-stdin", + cd: Path.expand("../assets", __DIR__) + ] + ] + +config :ui, UiWeb.Endpoint, + live_reload: [ + patterns: [ + ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + ~r"priv/gettext/.*(po)$", + ~r"lib/ui_web/{live,views}/.*(ex)$", + ~r"lib/ui_web/templates/.*(eex)$" + ] + ] + +config :logger, :console, format: "[$level] $message\n" + +# Set a higher stacktrace during development. Avoid configuring such +# in production as building large stacktraces may be expensive. +config :phoenix, :stacktrace_depth, 20 + +# Initialize plugs at runtime for faster development compilation +config :phoenix, :plug_init_mode, :runtime diff --git a/firmware/config/target.exs b/firmware/config/target.exs index f5c8fda..8e45d20 100644 --- a/firmware/config/target.exs +++ b/firmware/config/target.exs @@ -28,7 +28,7 @@ config :nerves_firmware_ssh, # Setting the node_name will enable Erlang Distribution. # Only enable this for prod if you understand the risks. -node_name = if Mix.env() != :prod, do: "firmware" +node_name = "esrom" config :nerves_init_gadget, ifname: "eth0", @@ -37,6 +37,18 @@ config :nerves_init_gadget, node_name: node_name, node_host: :mdns_domain +config :ui, UiWeb.Endpoint, + url: [host: "www.geokunis2.nl"], + http: [port: 80], + secret_key_base: "HEY05EB1dFVSu6KykKHuS4rQPQzSHv4F7mGVB/gnDLrIu75wE/ytBXy2TaL3A6RA", + root: Path.dirname(__DIR__), + server: true, + render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)], + pubsub: [name: Nerves.PubSub, adapter: Phoenix.PubSub.PG2], + code_reloader: false + +config :morse, :relay_pin, 17 + if File.exists?("config/secrets.exs") do import_config "secrets.exs" end diff --git a/ui/config/config.exs b/ui/config/config.exs deleted file mode 100644 index dc1d064..0000000 --- a/ui/config/config.exs +++ /dev/null @@ -1,29 +0,0 @@ -# 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 - -# Configures the endpoint -config :ui, UiWeb.Endpoint, - url: [host: "localhost"], - secret_key_base: "FkfuB09FEncz4aAi6hS6w5bsNast+D1P12MckXr5dlRdhtFJrKqgEhvhpTU3qzgh", - render_errors: [view: UiWeb.ErrorView, accepts: ~w(html json)], - pubsub: [name: Ui.PubSub, adapter: Phoenix.PubSub.PG2] - -# 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 - -config :morse, :relay_pin, 17 - -# 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" diff --git a/ui/config/dev.exs b/ui/config/dev.exs deleted file mode 100644 index 208e186..0000000 --- a/ui/config/dev.exs +++ /dev/null @@ -1,67 +0,0 @@ -use Mix.Config - -# For development, we disable any cache and enable -# debugging and code reloading. -# -# The watchers configuration can be used to run external -# watchers to your application. For example, we use it -# with webpack to recompile .js and .css sources. -config :ui, UiWeb.Endpoint, - http: [port: 4000], - debug_errors: true, - code_reloader: true, - check_origin: false, - watchers: [ - node: [ - "node_modules/webpack/bin/webpack.js", - "--mode", - "development", - "--watch-stdin", - cd: Path.expand("../assets", __DIR__) - ] - ] - -# ## SSL Support -# -# In order to use HTTPS in development, a self-signed -# certificate can be generated by running the following -# Mix task: -# -# mix phx.gen.cert -# -# Note that this task requires Erlang/OTP 20 or later. -# Run `mix help phx.gen.cert` for more information. -# -# The `http:` config above can be replaced with: -# -# https: [ -# port: 4001, -# cipher_suite: :strong, -# keyfile: "priv/cert/selfsigned_key.pem", -# certfile: "priv/cert/selfsigned.pem" -# ], -# -# If desired, both `http:` and `https:` keys can be -# configured to run both http and https servers on -# different ports. - -# Watch static and templates for browser reloading. -config :ui, UiWeb.Endpoint, - live_reload: [ - patterns: [ - ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - ~r"priv/gettext/.*(po)$", - ~r"lib/ui_web/{live,views}/.*(ex)$", - ~r"lib/ui_web/templates/.*(eex)$" - ] - ] - -# Do not include metadata nor timestamps in development logs -config :logger, :console, format: "[$level] $message\n" - -# Set a higher stacktrace during development. Avoid configuring such -# in production as building large stacktraces may be expensive. -config :phoenix, :stacktrace_depth, 20 - -# Initialize plugs at runtime for faster development compilation -config :phoenix, :plug_init_mode, :runtime diff --git a/ui/config/prod.exs b/ui/config/prod.exs deleted file mode 100644 index 1b6983b..0000000 --- a/ui/config/prod.exs +++ /dev/null @@ -1,55 +0,0 @@ -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 :ui, UiWeb.Endpoint, - url: [host: "example.com", port: 80], - cache_static_manifest: "priv/static/cache_manifest.json" - -# Do not print debug messages in production -config :logger, level: :info - -# ## 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 :ui, UiWeb.Endpoint, -# ... -# url: [host: "example.com", port: 443], -# https: [ -# :inet6, -# port: 443, -# cipher_suite: :strong, -# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), -# certfile: System.get_env("SOME_APP_SSL_CERT_PATH") -# ] -# -# The `cipher_suite` is set to `:strong` to support only the -# latest and more secure SSL ciphers. This means old browsers -# and clients may not be supported. You can set it to -# `:compatible` for wider support. -# -# `:keyfile` and `:certfile` expect an absolute path to the key -# and cert in disk or a relative path inside priv, for example -# "priv/ssl/server.key". For all supported SSL configuration -# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 -# -# We also recommend setting `force_ssl` in your endpoint, ensuring -# no data is ever sent via http, always redirecting to https: -# -# config :ui, UiWeb.Endpoint, -# force_ssl: [hsts: true] -# -# Check `Plug.SSL` for all available options in `force_ssl`. - -# Finally import the config/prod.secret.exs which loads secrets -# and configuration from environment variables. -import_config "prod.secret.exs" diff --git a/ui/config/prod.secret.exs b/ui/config/prod.secret.exs deleted file mode 100644 index 622dd97..0000000 --- a/ui/config/prod.secret.exs +++ /dev/null @@ -1,26 +0,0 @@ -# In this file, we load production configuration and secrets -# from environment variables. You can also hardcode secrets, -# although such is generally not recommended and you have to -# remember to add this file to your .gitignore. -use Mix.Config - -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 :ui, UiWeb.Endpoint, - http: [:inet6, port: String.to_integer(System.get_env("PORT") || "4000")], - secret_key_base: secret_key_base - -# ## Using releases (Elixir v1.9+) -# -# If you are doing OTP releases, you need to instruct Phoenix -# to start each relevant endpoint: -# -# config :ui, UiWeb.Endpoint, server: true -# -# Then you can assemble a release by calling `mix release`. -# See `mix help release` for more information. diff --git a/ui/config/test.exs b/ui/config/test.exs deleted file mode 100644 index 93fd96d..0000000 --- a/ui/config/test.exs +++ /dev/null @@ -1,10 +0,0 @@ -use Mix.Config - -# We don't run a server during test. If one is required, -# you can enable the server option below. -config :ui, UiWeb.Endpoint, - http: [port: 4002], - server: false - -# Print only warnings and errors during test -config :logger, level: :warn