From bb27cbcc8065987e7ad9d4a173ee4c86e1c22568 Mon Sep 17 00:00:00 2001 From: joescottdave Date: Mon, 20 Dec 2021 15:40:33 +0000 Subject: [PATCH] Rename environment variable to rails convention We have erroneously been using RELATIVE_URL_ROOT in place of the conventional RAILS_RELATIVE_URL_ROOT which has the added side effect of setting Rails.application.config.application_controller.relative_url_root which in turn prepends all routes generated by url_helpers. Test by starting rails console with RAILS_RELATIVE_ROOT_URL set include Rails.application.routes.url_helpers and call root_path --- Dockerfile | 6 +++--- config/environments/production.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3eefaed..c7bd930 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,13 +22,13 @@ RUN bundle install # Params ARG RAILS_ENV="production" ARG RAILS_SERVE_STATIC_FILES="true" -ARG RELATIVE_URL_ROOT="/app/root" +ARG RAILS_RELATIVE_URL_ROOT="/app/root" # Set environment variables and expose the running port ENV RAILS_ENV=$RAILS_ENV ENV RAILS_SERVE_STATIC_FILES=$RAILS_SERVE_STATIC_FILES -ENV RELATIVE_URL_ROOT=$RELATIVE_URL_ROOT -ENV SCRIPT_NAME=$RELATIVE_URL_ROOT +ENV RAILS_RELATIVE_URL_ROOT=$RAILS_RELATIVE_URL_ROOT +ENV SCRIPT_NAME=$RAILS_RELATIVE_URL_ROOT EXPOSE 3000 # Precompile assets and add entrypoint script diff --git a/config/environments/production.rb b/config/environments/production.rb index f93cc0e..b463819 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -78,7 +78,7 @@ config.logger = JsonRailsLogger::Logger.new($stdout) - config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || '/' + config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] || '/' config.accessibility_document_path = '/accessibility' config.privacy_document_path = '/privacy'