From 04c5121ed3c903a36c356b7b2398fa2e72f0bcdb Mon Sep 17 00:00:00 2001 From: astrilet Date: Tue, 4 Apr 2017 13:20:00 -0600 Subject: [PATCH 1/8] small config changes; added env variable to enable temp login in production --- app/controllers/users/omniauth_callbacks_controller.rb | 2 +- app/views/devise/sessions/new.html.erb | 2 +- config/blacklight.yml | 2 +- config/initializers/omniauth.rb | 2 +- config/solr.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 751b2c1..9062807 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,6 +1,6 @@ class Users::OmniauthCallbacksController < ApplicationController # TODO: Remove this once we figure out IST, this is only required for the omniauth developer provider - skip_before_action :verify_authenticity_token, only: :complete unless Rails.env.production? + skip_before_action :verify_authenticity_token, only: :complete unless (Rails.env.production? && !ENV['ENABLE_TMP_LOGINS']) def complete auth_hash = request.env['omniauth.auth'] diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 172ef2a..004e18e 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -6,7 +6,7 @@ <%= t('.login_button_text') %> -<%- if Rails.env.development? %> +<%- if Rails.env.development? || ENV['ENABLE_TMP_LOGINS'] %> <%# TODO: Temporary login form for local development until IST shibboleth issues gets resolved %> Sign in with Developer Account diff --git a/config/blacklight.yml b/config/blacklight.yml index 5d9a01e..1724ce9 100644 --- a/config/blacklight.yml +++ b/config/blacklight.yml @@ -6,5 +6,5 @@ test: &test url: <%= ENV['SOLR_TEST_URL'] || 'http://localhost:8985/solr/hydra-test' %> production: adapter: solr - url: <%= ENV['SOLR_URL'] || 'http://localhost:8983/solr/blacklight-core' %> + url: <%= ENV['SOLR_PROD_URL'] || 'http://localhost:8983/solr/blacklight-core' %> diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 480fcd7..77a2d3b 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -12,7 +12,7 @@ }, name: 'CCID' - provider :developer unless Rails.env.production? + provider :developer unless (Rails.env.production? && !ENV['ENABLE_TMP_LOGINS']) # By default in development mode, omniauth raises an exception when authentication fails # comment this line if you want to see the stacktrace from the actual provider when in `development` diff --git a/config/solr.yml b/config/solr.yml index 6a1d415..f3c9019 100644 --- a/config/solr.yml +++ b/config/solr.yml @@ -4,4 +4,4 @@ development: test: url: <%= ENV['SOLR_TEST_URL'] || 'http://localhost:8985/solr/hydra-test' %> production: - url: http://your.production.server:8080/bl_solr/core0 + url: <%= ENV['SOLR_PROD_URL'] || 'http://your.production.server:8080/bl_solr/core0' %> From 74e98df433de0dc1dbe771a3645635b7e2167832 Mon Sep 17 00:00:00 2001 From: astrilet Date: Thu, 6 Apr 2017 11:47:23 -0600 Subject: [PATCH 2/8] changes as discussed --- app/controllers/users/omniauth_callbacks_controller.rb | 3 ++- config/blacklight.yml | 6 +++--- config/fedora.yml | 6 +++--- config/initializers/omniauth.rb | 3 ++- config/solr.yml | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 9062807..a8f2461 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,6 +1,7 @@ class Users::OmniauthCallbacksController < ApplicationController # TODO: Remove this once we figure out IST, this is only required for the omniauth developer provider - skip_before_action :verify_authenticity_token, only: :complete unless (Rails.env.production? && !ENV['ENABLE_TMP_LOGINS']) + skip_before_action :verify_authenticity_token, only: :complete unless (Rails.env.production? || + ENV['ENABLE_TMP_LOGINS'].present?) def complete auth_hash = request.env['omniauth.auth'] diff --git a/config/blacklight.yml b/config/blacklight.yml index 1724ce9..37d8b2e 100644 --- a/config/blacklight.yml +++ b/config/blacklight.yml @@ -1,10 +1,10 @@ development: adapter: solr - url: <%= ENV['SOLR_DEVELOPMENT_URL'] || 'http://localhost:8983/solr/hydra-development' %> + url: <%= ENV['SOLR_URL'] || 'http://localhost:8983/solr/hydra-development' %> test: &test adapter: solr - url: <%= ENV['SOLR_TEST_URL'] || 'http://localhost:8985/solr/hydra-test' %> + url: <%= ENV['SOLR_URL'] || 'http://localhost:8985/solr/hydra-test' %> production: adapter: solr - url: <%= ENV['SOLR_PROD_URL'] || 'http://localhost:8983/solr/blacklight-core' %> + url: <%= ENV['SOLR_URL'] || 'http://localhost:8983/solr/blacklight-core' %> diff --git a/config/fedora.yml b/config/fedora.yml index 5e8056a..2e321da 100644 --- a/config/fedora.yml +++ b/config/fedora.yml @@ -1,15 +1,15 @@ development: user: fedoraAdmin password: fedoraAdmin - url: <%= ENV['FCREPO_DEVELOPMENT_URL'] || 'http://localhost:8984/rest' %> + url: <%= ENV['FCREPO_URL'] || 'http://localhost:8984/rest' %> base_path: /dev test: user: fedoraAdmin password: fedoraAdmin - url: <%= ENV['FCREPO_TEST_URL'] || 'http://localhost:8986/rest' %> + url: <%= ENV['FCREPO_URL'] || 'http://localhost:8986/rest' %> base_path: /test production: user: fedoraAdmin password: fedoraAdmin - url: <%= ENV['FCREPO_PROD_URL'] || 'http://localhost:8983/rest' %> + url: <%= ENV['FCREPO_URL'] || 'http://localhost:8983/rest' %> base_path: /prod diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 77a2d3b..61695c6 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -12,7 +12,8 @@ }, name: 'CCID' - provider :developer unless (Rails.env.production? && !ENV['ENABLE_TMP_LOGINS']) + provider :developer unless (Rails.env.production? || + ENV['ENABLE_TMP_LOGINS'].present?) # By default in development mode, omniauth raises an exception when authentication fails # comment this line if you want to see the stacktrace from the actual provider when in `development` diff --git a/config/solr.yml b/config/solr.yml index f3c9019..b9693f9 100644 --- a/config/solr.yml +++ b/config/solr.yml @@ -1,7 +1,7 @@ # This is a sample config file that points to a solr server for each environment development: - url: <%= ENV['SOLR_DEVELOPMENT_URL'] || 'http://localhost:8983/solr/hydra-development' %> + url: <%= ENV['SOLR_URL'] || 'http://localhost:8983/solr/hydra-development' %> test: - url: <%= ENV['SOLR_TEST_URL'] || 'http://localhost:8985/solr/hydra-test' %> + url: <%= ENV['SOLR_URL'] || 'http://localhost:8985/solr/hydra-test' %> production: - url: <%= ENV['SOLR_PROD_URL'] || 'http://your.production.server:8080/bl_solr/core0' %> + url: <%= ENV['SOLR_URL'] || 'http://your.production.server:8080/bl_solr/core0' %> From e53d922e784e8f55fd835315d750cef6577742a8 Mon Sep 17 00:00:00 2001 From: astrilet Date: Thu, 6 Apr 2017 12:49:34 -0600 Subject: [PATCH 3/8] fixing rubocop errors --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 2ff4b48..e7dc9c6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -80,3 +80,7 @@ RSpec/ExampleLength: RSpec/MultipleExpectations: Enabled: false + +# as discussed in issue#144 +Style/ParenthesesAroundCondition: + Enabled: false From f82fb73cc249cc281a4a44e78be821c12599dfe4 Mon Sep 17 00:00:00 2001 From: astrilet Date: Fri, 7 Apr 2017 13:49:11 -0600 Subject: [PATCH 4/8] switch unless ot if --- app/controllers/users/omniauth_callbacks_controller.rb | 3 +-- config/initializers/omniauth.rb | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index a8f2461..e316ec5 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,7 +1,6 @@ class Users::OmniauthCallbacksController < ApplicationController # TODO: Remove this once we figure out IST, this is only required for the omniauth developer provider - skip_before_action :verify_authenticity_token, only: :complete unless (Rails.env.production? || - ENV['ENABLE_TMP_LOGINS'].present?) + skip_before_action :verify_authenticity_token, only: :complete if (Rails.env.development? || ENV['ENABLE_TMP_LOGINS'].present?) def complete auth_hash = request.env['omniauth.auth'] diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 61695c6..0a286ba 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -12,8 +12,7 @@ }, name: 'CCID' - provider :developer unless (Rails.env.production? || - ENV['ENABLE_TMP_LOGINS'].present?) + provider :developer if (Rails.env.development? || ENV['ENABLE_TMP_LOGINS'].present?) # By default in development mode, omniauth raises an exception when authentication fails # comment this line if you want to see the stacktrace from the actual provider when in `development` From 4ecdab7611cc74efe2b2d41a8ed45172e9ae092b Mon Sep 17 00:00:00 2001 From: astrilet Date: Fri, 7 Apr 2017 16:32:10 -0600 Subject: [PATCH 5/8] fixed rubocop warning message --- app/controllers/users/omniauth_callbacks_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index e316ec5..0b5b037 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,6 +1,7 @@ class Users::OmniauthCallbacksController < ApplicationController # TODO: Remove this once we figure out IST, this is only required for the omniauth developer provider - skip_before_action :verify_authenticity_token, only: :complete if (Rails.env.development? || ENV['ENABLE_TMP_LOGINS'].present?) + skip_before_action :verify_authenticity_token, only: :complete if (Rails.env.development? || + ENV['ENABLE_TMP_LOGINS'].present?) def complete auth_hash = request.env['omniauth.auth'] From d8d1d94640fda4add73b947625878719893dee12 Mon Sep 17 00:00:00 2001 From: astrilet Date: Mon, 10 Apr 2017 09:39:47 -0600 Subject: [PATCH 6/8] moved Docker file into the repository --- Dockerfile | 22 ++++++++++++++++++++++ bin/start_hn2.sh | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Dockerfile create mode 100755 bin/start_hn2.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..317ddf7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ualibraries/ruby_plus2.3.3 +# https://github.com/ualbertalib/DIDockerImages/blob/master/RubyPlus/Dockerfile +RUN apt-get update -qq && \ + apt-get install -y libpq-dev \ + nodejs \ + libreoffice-core \ + libreoffice-base-core \ + libreoffice-common \ + imagemagick \ + unzip && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir /app +WORKDIR /app +ADD . /app +RUN echo "gem 'tinymce-rails-imageupload', github: 'PerfectlyNormal/tinymce-rails-imageupload'" >> /app/Gemfile +RUN cd /app && bundle install +RUN cd /app && rake assets:precompile +ADD bin/start_hn2.sh /usr/local/bin + +EXPOSE 3000 + diff --git a/bin/start_hn2.sh b/bin/start_hn2.sh new file mode 100755 index 0000000..425e54e --- /dev/null +++ b/bin/start_hn2.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# this is shell script to start HydraNorth2 running in docker container +# Maintainer: strilets@ualberta.ca + +#make sure that database has been created +while [ ! -e /db/${HYDRANORTH_DB:-hydranorth2dev} ] +do + sleep 2 +done + +cd /app + +#check if db has been migrated +if [ ! -e /db/initialized ]; then + sleep 10 && rake db:migrate && touch /db/initialized; +fi + +rails server -b 0.0.0.0 From 5d4788eb383206ae3e158b6be437589f471ca9cb Mon Sep 17 00:00:00 2001 From: astrilet Date: Tue, 11 Apr 2017 13:35:06 -0600 Subject: [PATCH 7/8] changes as discussed in the PR --- Dockerfile | 3 ++- README.md | 12 ++++++++++++ bin/start_hn2.sh | 18 ------------------ 3 files changed, 14 insertions(+), 19 deletions(-) delete mode 100755 bin/start_hn2.sh diff --git a/Dockerfile b/Dockerfile index 317ddf7..cd78be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ ADD . /app RUN echo "gem 'tinymce-rails-imageupload', github: 'PerfectlyNormal/tinymce-rails-imageupload'" >> /app/Gemfile RUN cd /app && bundle install RUN cd /app && rake assets:precompile -ADD bin/start_hn2.sh /usr/local/bin + +CMD rake db:migrate && rails server -b 0.0.0.0 EXPOSE 3000 diff --git a/README.md b/README.md index e972432..1579d4d 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,15 @@ This is not ideal and hopefully a temporary solution. But currently in developme Some helpful links for more information: * http://www.jeesty.com/shibboleth * https://docs.gitlab.com/ce/integration/shibboleth.html + +## Building docker image + + You can build docker image for Hydranorth2 following precedure below. + There is a copy of ualibraries/hydranorth2 image that can be pulled + from [dockerhub](https://hub.docker.com/r/ualibraries/hydranorth2/) + + ```shell + docker build -t ualibraries/hydranorth2 . + ``` + + diff --git a/bin/start_hn2.sh b/bin/start_hn2.sh deleted file mode 100755 index 425e54e..0000000 --- a/bin/start_hn2.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# this is shell script to start HydraNorth2 running in docker container -# Maintainer: strilets@ualberta.ca - -#make sure that database has been created -while [ ! -e /db/${HYDRANORTH_DB:-hydranorth2dev} ] -do - sleep 2 -done - -cd /app - -#check if db has been migrated -if [ ! -e /db/initialized ]; then - sleep 10 && rake db:migrate && touch /db/initialized; -fi - -rails server -b 0.0.0.0 From 1e8a457ca461f526aa4ee9b947a20f38cf7b4d73 Mon Sep 17 00:00:00 2001 From: astrilet Date: Tue, 11 Apr 2017 13:48:33 -0600 Subject: [PATCH 8/8] revert changes as Shane already did them --- .rubocop.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e7dc9c6..998a611 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -81,6 +81,3 @@ RSpec/ExampleLength: RSpec/MultipleExpectations: Enabled: false -# as discussed in issue#144 -Style/ParenthesesAroundCondition: - Enabled: false