From 7bb59dde9e521fd1108cd5ad5f6e844ac22ef585 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 28 Jan 2020 08:57:45 +0000 Subject: [PATCH] made docker container work with subdirectory (RAILS_RELATIVE_URL_ROOT) --- config.ru | 9 +-------- docker/precompile-assets.sh | 2 ++ docker/supervisord | 11 +++++++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/config.ru b/config.ru index 78f6f6434b9..c8fffca44b4 100644 --- a/config.ru +++ b/config.ru @@ -48,14 +48,7 @@ if defined?(Unicorn) && Rails.env.production? use Unicorn::WorkerKiller::MaxRequests, min_req, max_req end -## -# Returns true if the application should be run under a subdirectory. -def map_subdir? - # Don't map subdir when using Passenger as passenger takes care of that. - !defined?(::PhusionPassenger) -end - -subdir = map_subdir? && OpenProject::Configuration.rails_relative_url_root.presence +subdir = OpenProject::Configuration.rails_relative_url_root.presence map (subdir || '/') do use Rack::Protection::JsonCsrf diff --git a/docker/precompile-assets.sh b/docker/precompile-assets.sh index 334fb23a187..4f12938ad4f 100644 --- a/docker/precompile-assets.sh +++ b/docker/precompile-assets.sh @@ -3,6 +3,8 @@ set -e pushd "${APP_PATH}/frontend" +export NG_CLI_ANALYTICS=ci # so angular cli doesn't block waiting for user input + # Installing frontend dependencies RAILS_ENV=production npm install diff --git a/docker/supervisord b/docker/supervisord index 59e0fbad80b..9adf4b3a9b8 100755 --- a/docker/supervisord +++ b/docker/supervisord @@ -68,9 +68,8 @@ migrate() { wait_for_postgres pushd $APP_PATH >/dev/null /etc/init.d/memcached start - bundle exec rake db:migrate db:seed db:structure:dump + bundle exec rake db:migrate db:seed /etc/init.d/memcached stop - chown "$APP_USER.$APP_USER" db/structure.sql popd >/dev/null } @@ -111,5 +110,13 @@ fi echo "-----> Database setup finished." echo " On first installation, the default admin credentials are login: admin, password: admin" +if [ -n "$OPENPROJECT_RAILS__RELATIVE__URL__ROOT" ]; then + echo + echo "-----> Precompiling assets since RAILS_RELATIVE_URL_ROOT is set. This may take a minute." + RAILS_RELATIVE_URL_ROOT=$OPENPROJECT_RAILS__RELATIVE__URL__ROOT bash /app/docker/precompile-assets.sh + echo "-----> Asset precompilation finished." + echo +fi + echo "-----> Launching supervisord..." exec /usr/bin/supervisord -c $APP_PATH/docker/supervisord.conf -e ${SUPERVISORD_LOG_LEVEL}