docbrown/config/initializers/0_application_config.rb
Dmitry Maksyoma be07697d6d
Adapt dev env to run on a remote box (#8232)
* Adapt dev env to run on a remote box

* webpack-dev-server ignores CLI arguments, so switched to environment
  variables.
* Dynamically determine remote webpack host via APP_DOMAIN environment
  variable, defined in application.yml.
* Setup content security policy to allow connecting to webpack on a
  remote box, defined by APP_DOMAIN environment variable.

* Make Webpacker listen on 0.0.0.0

* Account for APP_DOMAIN port

* Add support for URI scheme and tests

* Fix a spec by disabling a Rubocop linter
2020-06-18 13:01:49 +02:00

15 lines
336 B
Ruby

ENVied.require(*ENV["ENVIED_GROUPS"] || Rails.groups)
class ApplicationConfig
URI_REGEXP = %r{(?<scheme>https?://)?(?<host>.+?)(?<port>:\d+)?$}.freeze
def self.[](key)
ENVied.send(key)
end
def self.app_domain_no_port
app_domain = self["APP_DOMAIN"]
match = app_domain.match(URI_REGEXP)
match[:host]
end
end