diff --git a/.circleci/config.yml b/.circleci/config.yml
index 5eaa8314..88536d25 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- - image: circleci/ruby:2.5-stretch
+ - image: circleci/ruby:2.5.1
working_directory: ~/app
steps:
- run:
diff --git a/.env b/.env
new file mode 100644
index 00000000..336ada13
--- /dev/null
+++ b/.env
@@ -0,0 +1 @@
+RAILS_ENV=development
diff --git a/.gitignore b/.gitignore
index 0703d84b..27e1f798 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,9 +18,6 @@
/log/*.log.*
/tmp
-# Ignore dotenv
-.env
-
# Ignore coverage
/coverage
@@ -37,3 +34,5 @@ blazegraph*
public/ns*
.vscode/*
+
+sunspot-solr.pid
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..4588eb8d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,38 @@
+FROM ruby:2.5.1 as builder
+
+# Necessary for bundler to properly install some gems
+ENV LANG C.UTF-8
+ENV LC_ALL C.UTF-8
+
+RUN gem install bundler
+
+RUN apt-get update -qq && apt-get upgrade -y && \
+ apt-get install -y build-essential libpq-dev mysql-client cmake libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev phantomjs && \
+ apt-get install -y openjdk-8-jre openjdk-8-jdk openjdk-8-jdk-headless && \
+ update-alternatives --config java
+
+RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
+RUN tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
+RUN ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin
+
+RUN mkdir /data
+WORKDIR /data
+
+ADD Gemfile /data/Gemfile
+ADD Gemfile.lock /data/Gemfile.lock
+RUN mkdir /data/build
+
+ARG RAILS_ENV=development
+ENV RAILS_ENV=${RAILS_ENV}
+
+ADD ./build/install_gems.sh /data/build
+RUN ./build/install_gems.sh
+
+ADD . /data
+
+FROM builder
+
+RUN if [ "${RAILS_ENV}" = "production" ]; then \
+ echo "Precompiling assets with $RAILS_ENV environment"; \
+ RAILS_ENV=$RAILS_ENV SECRET_KEY_BASE=temporary bundle exec rails assets:precompile; \
+ fi
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 3fe74773..031f71bc 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,7 +9,7 @@ gem 'actionpack-page_caching'
gem 'sqlite3', '~> 1.3.13'
gem 'mysql2', '~> 0.3.13'
# Use SCSS for stylesheets
-gem 'sass-rails', '~> 4.0.3'
+gem 'sass-rails'
# Use Bootstrap
gem 'bootstrap-sass', '~> 3.4'
gem 'autoprefixer-rails'
@@ -62,7 +62,12 @@ gem 'font-awesome-rails'
gem 'attr_extras'
-gem 'capistrano', '~> 2.0'
+gem 'capistrano', '~> 3.0'
+gem 'capistrano-passenger'
+gem 'capistrano-rails'
+gem 'capistrano-rbenv'
+gem 'capistrano3-puma'
+gem 'puma'
gem 'responders', '~> 2.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index e700c54c..9446b1a4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -66,10 +66,12 @@ GEM
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
+ airbrussh (1.3.2)
+ sshkit (>= 1.6.1, != 1.7.0)
arel (6.0.4)
ast (2.4.0)
attr_extras (6.2.1)
- autoprefixer-rails (9.6.0)
+ autoprefixer-rails (9.6.1)
execjs
awesome_print (1.8.0)
bcp47 (0.3.3)
@@ -86,12 +88,25 @@ GEM
builder (3.2.3)
byebug (11.0.1)
cancan (1.6.10)
- capistrano (2.15.9)
- highline
- net-scp (>= 1.0.0)
- net-sftp (>= 2.0.0)
- net-ssh (>= 2.0.14)
- net-ssh-gateway (>= 1.1.0)
+ capistrano (3.11.0)
+ airbrussh (>= 1.0.0)
+ i18n
+ rake (>= 10.0.0)
+ sshkit (>= 1.9.0)
+ capistrano-bundler (1.6.0)
+ capistrano (~> 3.1)
+ capistrano-passenger (0.2.0)
+ capistrano (~> 3.0)
+ capistrano-rails (1.4.0)
+ capistrano (~> 3.1)
+ capistrano-bundler (~> 1.1)
+ capistrano-rbenv (2.1.4)
+ capistrano (~> 3.1)
+ sshkit (~> 1.3)
+ capistrano3-puma (4.0.0)
+ capistrano (~> 3.7)
+ capistrano-bundler
+ puma (~> 4.0)
capybara (2.18.0)
addressable
mini_mime (>= 0.1.3)
@@ -112,10 +127,10 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
- config (1.7.2)
- activesupport (>= 3.0)
+ config (2.0.0)
+ activesupport (>= 4.2)
deep_merge (~> 1.2, >= 1.2.1)
- dry-validation (~> 0.12, >= 0.12.2, < 1.0.0)
+ dry-schema (~> 1.0)
coveralls (0.8.23)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
@@ -126,7 +141,7 @@ GEM
safe_yaml (~> 1.0.0)
crass (1.0.4)
database_cleaner (1.7.0)
- ddtrace (0.24.0)
+ ddtrace (0.25.0)
msgpack
debug_inspector (0.0.3)
deep_merge (1.2.1)
@@ -141,40 +156,42 @@ GEM
diff-lcs (1.3)
diffy (3.3.0)
docile (1.3.2)
- domain_name (0.5.20180417)
+ domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
- dotenv (2.7.2)
- dotenv-rails (2.7.2)
- dotenv (= 2.7.2)
+ dotenv (2.7.4)
+ dotenv-rails (2.7.4)
+ dotenv (= 2.7.4)
railties (>= 3.2, < 6.1)
dry-configurable (0.8.3)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
- dry-container (0.7.1)
+ dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
- dry-core (0.4.7)
+ dry-core (0.4.8)
concurrent-ruby (~> 1.0)
dry-equalizer (0.2.2)
dry-inflector (0.1.2)
- dry-logic (0.6.1)
+ dry-initializer (3.0.1)
+ dry-logic (1.0.2)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
- dry-types (0.14.1)
+ dry-schema (1.3.1)
+ concurrent-ruby (~> 1.0)
+ dry-configurable (~> 0.8, >= 0.8.3)
+ dry-core (~> 0.4)
+ dry-equalizer (~> 0.2)
+ dry-initializer (~> 3.0)
+ dry-logic (~> 1.0)
+ dry-types (~> 1.0)
+ dry-types (1.1.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
- dry-equalizer (~> 0.2)
+ dry-equalizer (~> 0.2, >= 0.2.2)
dry-inflector (~> 0.1, >= 0.1.2)
- dry-logic (~> 0.5, >= 0.5)
- dry-validation (0.13.3)
- concurrent-ruby (~> 1.0)
- dry-configurable (~> 0.1, >= 0.1.3)
- dry-core (~> 0.2, >= 0.2.1)
- dry-equalizer (~> 0.2)
- dry-logic (~> 0.5, >= 0.5.0)
- dry-types (~> 0.14.0)
+ dry-logic (~> 1.0, >= 1.0.2)
ebnf (1.0.0)
rdf (~> 1.1)
sxp (~> 0.1, >= 0.1.3)
@@ -207,8 +224,6 @@ GEM
temple (>= 0.8.0)
tilt
hashdiff (0.4.0)
- highline (2.0.2)
- hike (1.2.3)
honeycomb-beeline (0.8.0)
activerecord-honeycomb (>= 0.4.0)
faraday-honeycomb (>= 0.3.0)
@@ -278,24 +293,21 @@ GEM
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
- mini_mime (1.0.1)
+ mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.6)
libv8 (>= 6.9.411)
minitest (5.11.3)
- msgpack (1.2.10)
+ msgpack (1.3.0)
multi_json (1.13.1)
multipart-post (2.1.1)
mysql2 (0.3.21)
net-http-persistent (2.9.4)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
- net-sftp (2.1.2)
- net-ssh (>= 2.6.5)
net-ssh (5.2.0)
- net-ssh-gateway (2.0.0)
- net-ssh (>= 4.0.0)
netrc (0.11.0)
+ nio4r (2.4.0)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
octokit (4.14.0)
@@ -328,7 +340,9 @@ GEM
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
- public_suffix (3.1.0)
+ public_suffix (3.1.1)
+ puma (4.0.1)
+ nio4r (~> 2.0)
rack (1.6.11)
rack-honeycomb (0.5.0)
libhoney (>= 1.5.0)
@@ -361,6 +375,9 @@ GEM
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.2)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
rdf (1.99.1)
link_header (~> 0.0, >= 0.0.8)
rdf-aggregate-repo (1.99.0)
@@ -426,7 +443,7 @@ GEM
rsolr (2.2.1)
builder (>= 2.1.2)
faraday (>= 0.9.0)
- rspec-core (3.8.1)
+ rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
@@ -455,12 +472,17 @@ GEM
ruby-progressbar (1.10.1)
rugged (0.28.2)
safe_yaml (1.0.5)
- sass (3.2.19)
- sass-rails (4.0.5)
- railties (>= 4.0.0, < 5.0)
- sass (~> 3.2.2)
- sprockets (~> 2.8, < 3.0)
- sprockets-rails (~> 2.0)
+ sass (3.7.4)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.7)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
sassc (2.0.1)
ffi (~> 1.9)
rake
@@ -498,27 +520,28 @@ GEM
spring (2.1.0)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
- sprockets (2.12.5)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- sprockets-rails (2.3.3)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- sprockets (>= 2.8, < 4.0)
+ sprockets (3.7.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
sqlite3 (1.3.13)
- sunspot (2.3.0)
+ sshkit (1.19.1)
+ net-scp (>= 1.1.2)
+ net-ssh (>= 2.8.0)
+ sunspot (2.5.0)
pr_geohash (~> 1.0)
rsolr (>= 1.1.1, < 3)
- sunspot_solr (2.3.0)
+ sunspot_solr (2.5.0)
sxp (0.1.5)
temple (0.8.1)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (0.20.3)
thread_safe (0.3.6)
- tilt (1.4.1)
+ tilt (2.0.9)
timecop (0.9.1)
tins (1.6.0)
turbolinks (5.2.0)
@@ -573,7 +596,11 @@ DEPENDENCIES
bootstrap-will_paginate
brakeman
cancan
- capistrano (~> 2.0)
+ capistrano (~> 3.0)
+ capistrano-passenger
+ capistrano-rails
+ capistrano-rbenv
+ capistrano3-puma
capybara
capybara-screenshot
coffee-rails (~> 4.0.0)
@@ -601,6 +628,7 @@ DEPENDENCIES
pry-git
pry-rails
pry-remote
+ puma
rack-honeycomb (~> 0.5.0)
rails (~> 4.2.11.1)
rdf-vocab
@@ -610,7 +638,7 @@ DEPENDENCIES
rubocop
rubocop-rspec
rugged
- sass-rails (~> 4.0.3)
+ sass-rails
sdoc (~> 0.4.0)
sequel
shoulda-matchers
@@ -634,4 +662,4 @@ DEPENDENCIES
will_paginate (~> 3.1.0)
BUNDLED WITH
- 1.17.1
+ 1.17.3
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0686f638..d6f99da3 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,7 +12,7 @@ def skip_render_on_cached_page
@skip_render = true
end
- if %w[production staging development].include? Rails.env
+ if %w[production staging].include? Rails.env
def append_info_to_payload(payload)
super(payload)
Rack::Honeycomb.add_field(request.env, 'classname', self.class.name)
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index df5e98dd..2e094a8c 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -7,8 +7,8 @@
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => false %>
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => false %>
<%= render :partial => 'shared/analytics' %>
<%= csrf_meta_tags unless @skip_render %>
diff --git a/bin/bundle b/bin/bundle
index 66e9889e..524dfd3f 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -1,3 +1,105 @@
#!/usr/bin/env ruby
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-load Gem.bin_path('bundler', 'bundle')
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
+
+ def env_var_version
+ ENV["BUNDLER_VERSION"]
+ end
+
+ def cli_arg_version
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ bundler_version = nil
+ update_index = nil
+ ARGV.each_with_index do |a, i|
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ bundler_version = a
+ end
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+ bundler_version = $1 || ">= 0.a"
+ update_index = i
+ end
+ bundler_version
+ end
+
+ def gemfile
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ return gemfile if gemfile && !gemfile.empty?
+
+ File.expand_path("../../Gemfile", __FILE__)
+ end
+
+ def lockfile
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
+ end
+
+ def lockfile_version
+ return unless File.file?(lockfile)
+ lockfile_contents = File.read(lockfile)
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+ Regexp.last_match(1)
+ end
+
+ def bundler_version
+ @bundler_version ||= begin
+ env_var_version || cli_arg_version ||
+ lockfile_version || "#{Gem::Requirement.default}.a"
+ end
+ end
+
+ def load_bundler!
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+ # must dup string for RG < 1.8 compatibility
+ activate_bundler(bundler_version.dup)
+ end
+
+ def activate_bundler(bundler_version)
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
+ bundler_version = "< 2"
+ end
+ gem_error = activation_error_handling do
+ gem "bundler", bundler_version
+ end
+ return if gem_error.nil?
+ require_error = activation_error_handling do
+ require "bundler/version"
+ end
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
+ exit 42
+ end
+
+ def activation_error_handling
+ yield
+ nil
+ rescue StandardError, LoadError => e
+ e
+ end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/byebug b/bin/byebug
new file mode 100755
index 00000000..16f20bbd
--- /dev/null
+++ b/bin/byebug
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'byebug' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("byebug", "byebug")
diff --git a/bin/cap b/bin/cap
new file mode 100755
index 00000000..db774dc5
--- /dev/null
+++ b/bin/cap
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'cap' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("capistrano", "cap")
diff --git a/bin/capify b/bin/capify
new file mode 100755
index 00000000..68921002
--- /dev/null
+++ b/bin/capify
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'capify' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("capistrano", "capify")
diff --git a/bin/coveralls b/bin/coveralls
new file mode 100755
index 00000000..3b7b06ec
--- /dev/null
+++ b/bin/coveralls
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'coveralls' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("coveralls", "coveralls")
diff --git a/bin/dotenv b/bin/dotenv
new file mode 100755
index 00000000..a8ec8c76
--- /dev/null
+++ b/bin/dotenv
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'dotenv' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("dotenv", "dotenv")
diff --git a/bin/passenger b/bin/passenger
new file mode 100755
index 00000000..8f63dd8a
--- /dev/null
+++ b/bin/passenger
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'passenger' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("passenger", "passenger")
diff --git a/bin/pry b/bin/pry
new file mode 100755
index 00000000..bfcc3d48
--- /dev/null
+++ b/bin/pry
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pry' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("pry", "pry")
diff --git a/bin/pry-remote b/bin/pry-remote
new file mode 100755
index 00000000..34d1ea16
--- /dev/null
+++ b/bin/pry-remote
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pry-remote' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("pry-remote", "pry-remote")
diff --git a/bin/puma b/bin/puma
new file mode 100755
index 00000000..880935b2
--- /dev/null
+++ b/bin/puma
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'puma' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("puma", "puma")
diff --git a/bin/pumactl b/bin/pumactl
new file mode 100755
index 00000000..b698e6e9
--- /dev/null
+++ b/bin/pumactl
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pumactl' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("puma", "pumactl")
diff --git a/bin/rackup b/bin/rackup
new file mode 100755
index 00000000..3ac4a5a7
--- /dev/null
+++ b/bin/rackup
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rackup' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rack", "rackup")
diff --git a/bin/rails b/bin/rails
index 7feb6a30..7fd59cc7 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,8 +1,29 @@
#!/usr/bin/env ruby
-begin
- load File.expand_path("../spring", __FILE__)
-rescue LoadError
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rails' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
end
-APP_PATH = File.expand_path('../../config/application', __FILE__)
-require_relative '../config/boot'
-require 'rails/commands'
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("railties", "rails")
diff --git a/bin/rake b/bin/rake
index 8017a027..9275675e 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,8 +1,29 @@
#!/usr/bin/env ruby
-begin
- load File.expand_path("../spring", __FILE__)
-rescue LoadError
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rake' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
end
-require_relative '../config/boot'
-require 'rake'
-Rake.application.run
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rake", "rake")
diff --git a/bin/rspec b/bin/rspec
new file mode 100755
index 00000000..a6c78521
--- /dev/null
+++ b/bin/rspec
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rspec' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rspec-core", "rspec")
diff --git a/bin/spring b/bin/spring
index 7f24d96f..4a965880 100755
--- a/bin/spring
+++ b/bin/spring
@@ -1,18 +1,29 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
-# This file loads spring without using Bundler, in order to be fast
-# It gets overwritten when you run the `spring binstub` command
+#
+# This file was generated by Bundler.
+#
+# The application 'spring' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
-unless defined?(Spring)
- require "rubygems"
- require "bundler"
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
- if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
- ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
- ENV["GEM_HOME"] = ""
- Gem.paths = ENV
+bundle_binstub = File.expand_path("../bundle", __FILE__)
- gem "spring", match[1]
- require "spring/binstub"
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("spring", "spring")
diff --git a/build/entrypoint.sh b/build/entrypoint.sh
new file mode 100755
index 00000000..ea0efc4f
--- /dev/null
+++ b/build/entrypoint.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+echo "Building ${RAILS_ENV}"
+
+./build/install_gems.sh
+
+# Do not auto-migrate for production environment
+if [ "${RAILS_ENV}" != 'production' ]; then
+ ./build/validate_migrated.sh
+fi
+
+# Submit a marker to honeycomb marking the time the application starts booting
+if [ "${RAILS_ENV}" = 'production' ]; then
+ curl https://api.honeycomb.io/1/markers/sa-rails-${RAILS_ENV} -X POST -H "X-Honeycomb-Team: ${HONEYCOMB_WRITEKEY}" -d "{\"message\":\"${RAILS_ENV} - ${DEPLOYED_VERSION} - booting\", \"type\":\"deploy\"}"
+fi
\ No newline at end of file
diff --git a/build/install_gems.sh b/build/install_gems.sh
new file mode 100755
index 00000000..b6b6810d
--- /dev/null
+++ b/build/install_gems.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "${RAILS_ENV}" = 'production' ]; then
+ echo "Bundle install without development or test gems."
+ bundle install --without development test -j $(nproc)
+else
+ bundle install -j $(nproc)
+fi
\ No newline at end of file
diff --git a/build/validate_migrated.sh b/build/validate_migrated.sh
new file mode 100755
index 00000000..432d0a37
--- /dev/null
+++ b/build/validate_migrated.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ "${RAILS_ENV}" = 'production' ]; then
+ echo "Cannot auto-migrate ${RAILS_ENV} database, exiting"
+ exit 1
+fi
+
+echo "Checking ${RAILS_ENV} database migration status and auto-migrating if necessary."
+# If the migration status can't be read or is not fully migrated
+# then update the database with latest migrations
+if bundle exec rake db:migrate:status &> /dev/null; then
+ bundle exec rake db:migrate
+fi
\ No newline at end of file
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 00000000..1f3e9159
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,47 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum, this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted this block will be run, if you are using `preload_app!`
+# option you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
\ No newline at end of file
diff --git a/config/puma/development.rb b/config/puma/development.rb
new file mode 100644
index 00000000..fc490622
--- /dev/null
+++ b/config/puma/development.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal:true
+
+bind 'tcp://0.0.0.0:3000'
+# worker pools kill the capability for ruby-debug-ide integration
+# workers 1
+preload_app!
+environment 'development'
+daemonize false
\ No newline at end of file
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
new file mode 100644
index 00000000..26e02cd9
--- /dev/null
+++ b/docker-compose.override.yml
@@ -0,0 +1,21 @@
+# Example for exposing the load balancer for local dev and remote debugging; just copy this to docker-compose.override.yml
+version: '3'
+
+services:
+ lb:
+ expose:
+ - 80
+ ports:
+ - 80:80
+ server:
+ # Uncomment the following line to run the web application ready for a debugger (RubyMine, VSCode) to attach
+ #command: bash -c "rm -f tmp/pids/server.pid && bundle exec rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails server -p 3000 -b 0.0.0.0"
+ ports:
+ - 3000:3000
+ - 1234:1234
+ expose:
+ - 3000
+ - 1234
+ networks:
+ internal:
+ external:
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..47a75b67
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,163 @@
+version: '3'
+
+volumes:
+ app:
+ blazegraph:
+ db:
+ solr:
+ bundled:
+
+networks:
+ external:
+ internal:
+
+services:
+ ##
+ # Basic image for the rails application server, see Dockerfile
+ app: &app
+ build:
+ context: .
+ dockerfile: Dockerfile
+ volumes:
+ - .:/data
+ - app:/data/tmp/uploads
+ - bundled:/usr/local/bundle
+ tmpfs:
+ - /data/log
+ networks:
+ internal:
+ external:
+
+ ##
+ # Run the application in the currently set RAILS_ENV, set to development by default in the .env file.
+ server: &server
+ <<: *app
+ environment:
+ - RAILS_ENV=${RAILS_ENV}
+ - CVM_SOLR_URL=http://localhost:8983/solr/default
+ - CVM_TRIPLESTORE_URL=http://localhost:9999/blazegraph/namespace/development/sparql
+ - BLAZEGRAPH_URL=http://localhost:9999/blazegraph
+
+ # Ideally we will replace this set of commands with an entrypoint script that checks to see if these
+ # have been run already have been run and if so it just starts the server without the first three commands
+ # taking time to run.
+ command: >
+ bash -c "bundle exec rake triplestore_adapter:blazegraph:reset &&
+ ./build/entrypoint.sh &&
+ rake git_dev:create_dev_repo &&
+ rake sunspot:solr:start &&
+ bundle exec puma -C config/puma/development.rb --dir /data --pidfile /data/tmp/pids/puma.pid -b tcp://0.0.0.0:3000"
+ depends_on:
+ - db
+ - db_test
+ - solr
+ - blazegraph
+ expose:
+ - 3000
+
+ ##
+ # Test environment for application
+ test: &test
+ <<: *server
+ environment:
+ - RAILS_ENV=test
+ - CVM_SOLR_URL=http://localhost:8983/solr/default
+ - CVM_TRIPLESTORE_URL=http://localhost:9999/blazegraph/namespace/test/sparql
+ - BLAZEGRAPH_URL=http://localhost:9999/blazegraph
+ depends_on:
+ - db_test
+ - solr-test
+ - blazegraph
+ command: >
+ bash -c "bundle exec rake triplestore_adapter:blazegraph:reset &&
+ ./build/entrypoint.sh &&
+ rake git_dev:create_dev_repo &&
+ bundle exec puma -b tcp://0.0.0.0:3001 -e test"
+ expose:
+ - 3001
+
+ ##
+ # Blazegraph server
+ blazegraph-image: &blazegraph-image
+ image: lyrasis/blazegraph:2.1.5
+ expose:
+ - 8080
+ networks:
+ internal:
+ command: bash -c "chmod a+wx /data && ./entrypoint.sh"
+ blazegraph:
+ <<: *blazegraph-image
+ volumes:
+ - blazegraph:/data
+ - ./config/blazegraph/RWStore.properties:/data/RWStore.properties
+
+ ##
+ # Run an instance of MySQL with a database named 'development' for running specs. See config/database.yml
+ db:
+ image: mysql:5.7
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=12341234
+ - MYSQL_PASSWORD=12341234
+ - MYSQL_DATABASE=development
+ volumes:
+ - db:/var/lib/mysql
+ - ./config/mysql/mysqld.cnf:/etc/mysql/conf.d/custom.cnf
+ networks:
+ internal:
+
+ ##
+ # Run an instance of MySQL with a database named 'test' for running specs. See config/database.yml. Has no volume
+ # and doesn't intend on persisting data across sessions.
+ db_test:
+ image: mysql:5.7
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=12341234
+ - MYSQL_PASSWORD=12341234
+ - MYSQL_DATABASE=test
+ volumes:
+ - ./config/mysql/mysqld.cnf:/etc/mysql/conf.d/custom.cnf
+ networks:
+ internal:
+
+ solr: &solr
+ image: solr:alpine
+ expose:
+ - 8983
+ volumes:
+ - solr:/opt/solr/server/solr/mycores
+ - ./solr/conf:/opt/solr/server/solr/configsets/_default/conf
+ entrypoint:
+ - docker-entrypoint.sh
+ - solr-precreate
+ - hydra-${RAILS_ENV}
+ networks:
+ internal:
+
+ ##
+ # Run SOLR, precreating a core related to the RAILS_ENV currently set, persists data across sessions in a named volume.
+ solr-test:
+ <<: *solr
+ entrypoint:
+ - docker-entrypoint.sh
+ - solr-precreate
+ - hydra-test
+
+ ##
+ # Load balancer, although not strictly necessary.. would allow the app to work with regular port 80
+ lb:
+ image: dockercloud/haproxy:1.5.3
+ links:
+ - server
+ environment:
+ - DOCKER_TLS_VERIFY
+ - DOCKER_HOST
+ - DOCKER_CERT_PATH
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ # You must uncomment this line if and only if you are running docker-machine
+ # - $DOCKER_CERT_PATH:$DOCKER_CERT_PATH
+ networks:
+ internal:
+ external:
\ No newline at end of file