From 2c6fc3bb2594573531ac95ae2e1793a8140cec04 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 30 Jan 2020 16:44:30 +1100 Subject: [PATCH] feat: support setting the application base URL using environment variable PACT_BROKER_BASE_URL --- README.md | 1 + pact_broker/config.ru | 1 + pact_broker/docker_configuration.rb | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index b5dfb41..1ed61c0 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Set the environment variable `PACT_BROKER_LOG_LEVEL` to one of `DEBUG`, `INFO`, ## Other environment variables * PACT_BROKER_PORT - the port that the Pact Broker application runs on. Defaults to 9292. +* PACT_BROKER_BASE_URL - optional. If you find that the URLs generated by the API are using an IP instead of a hostname, you can set this environment variable to force the desired base URL. Must include the port if it's a non-standard one. eg. `https://my-broker:9292`. Is not currently used for links in the UI. * PACT_BROKER_DISABLE_SSL_VERIFICATION - `false` by default, may be set to `true`. * PACT_BROKER_BASE_EQUALITY_ONLY_ON_CONTENT_THAT_AFFECTS_VERIFICATION_RESULTS - `true` by default, may be set to `false`. * PACT_BROKER_ORDER_VERSIONS_BY_DATE - `true` by default. Setting this to false is deprecated. diff --git a/pact_broker/config.ru b/pact_broker/config.ru index e73f75c..a17aa3b 100644 --- a/pact_broker/config.ru +++ b/pact_broker/config.ru @@ -12,6 +12,7 @@ app = PactBroker::App.new do | config | config.logger = $logger config.database_connection = create_database_connection(config.logger) config.database_connection.timezone = :utc + config.base_url = dc.base_url config.webhook_host_whitelist = dc.webhook_host_whitelist config.webhook_http_method_whitelist = dc.webhook_http_method_whitelist config.webhook_scheme_whitelist = dc.webhook_scheme_whitelist diff --git a/pact_broker/docker_configuration.rb b/pact_broker/docker_configuration.rb index c1a53f6..6c84da7 100644 --- a/pact_broker/docker_configuration.rb +++ b/pact_broker/docker_configuration.rb @@ -47,6 +47,10 @@ def order_versions_by_date end end + def base_url + env(:base_url) + end + def env name @env["PACT_BROKER_#{name.to_s.upcase}"] end