From bac6910602d7c060ce76f99fb0e7f5c698af43dd Mon Sep 17 00:00:00 2001 From: ThePieMonster Date: Sun, 11 Apr 2021 15:54:22 -0500 Subject: [PATCH] Update Gemfile Fix application.rb Add logging to docker scripts Include feature to run on K8S with custom env file --- Gemfile | 418 +++++++++++++++++++-------------------- Gemfile.lock | 147 +++++++------- config/application.rb | 103 +++++----- docker/scripts/prepare | 7 + docker/scripts/setup_env | 45 ++++- 5 files changed, 384 insertions(+), 336 deletions(-) diff --git a/Gemfile b/Gemfile index 893850e285..cd93d753ab 100644 --- a/Gemfile +++ b/Gemfile @@ -1,209 +1,209 @@ -source 'https://rubygems.org' - -ruby '>=2.5.0' - -# Ensure github repositories are fetched using HTTPS -git_source(:github) do |repo_name| - "https://github.com/#{repo_name}.git" -end - -# Load vendored dotenv gem and .env file -require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb') -GemfileHelper.load_dotenv do |dotenv_dir| - path dotenv_dir do - gem 'dotenv' - gem 'dotenv-rails' - end -end - -# Introduces a scope for gem loading based on a condition -def if_true(condition) - if condition - yield - else - # When not including the gems, we still want our Gemfile.lock - # to include them, so we scope them to an unsupported platform. - platform :ruby_18, &proc - end -end - -# Optional libraries. To conserve RAM, comment out any that you don't need, -# then run `bundle` and commit the updated Gemfile and Gemfile.lock. -gem 'twilio-ruby', '~> 3.11.5' # TwilioAgent -gem 'ruby-growl', '~> 4.1.0' # GrowlAgent -gem 'net-ftp-list', '~> 3.2.8' # FtpsiteAgent -gem 'forecast_io', '~> 2.0.0' # WeatherAgent -gem 'rturk', '~> 2.12.1' # HumanTaskAgent -gem 'erector', github: 'dsander/erector', branch: 'rails6' -gem 'hipchat', '~> 1.2.0' # HipchatAgent -gem 'mini_racer', '~> 0.2.4' # JavaScriptAgent -gem 'xmpp4r', '~> 0.5.6' # JabberAgent -gem 'mqtt' # MQTTAgent -gem 'slack-notifier', '~> 1.0.0' # SlackAgent -gem 'hypdf', '~> 1.0.10' # PDFInfoAgent - -# Weibo Agents -# FIXME needs to loosen omniauth dependency, add rest-client -gem 'weibo_2', github: 'albertsun/weibo_2', branch: 'master' - -# GoogleCalendarPublishAgent and GoogleTranslateAgent -gem 'google-api-client', '~> 0.13' -gem 'google-cloud-translate', '~> 1.0.0', require: 'google/cloud/translate' - -# Twitter Agents -gem 'twitter', github: 'sferik/twitter' # Must to be loaded before cantino-twitter-stream. -gem 'twitter-stream', github: 'cantino/twitter-stream', branch: 'huginn' -gem 'omniauth-twitter', '~> 1.3.0' - -# Tumblr Agents -# until merge of https://github.com/tumblr/tumblr_client/pull/61 -gem 'tumblr_client', github: 'albertsun/tumblr_client', branch: 'master', ref: 'e046fe6e39291c173add0a49081630c7b60a36c7' -gem 'omniauth-tumblr', '~> 1.2' - -# Dropbox Agents -gem 'dropbox-api', github: 'dsander/dropbox-api', ref: '86cb7b5a1254dc5b054de7263835713c4c1018c7' -gem 'omniauth-dropbox-oauth2', github: 'bamorim/omniauth-dropbox-oauth2', ref: '35046706fb781ed3b57dfb9c3cd44ed0f3d3f8ea' - -# UserLocationAgent -gem 'haversine' - -# EvernoteAgent -gem 'omniauth-evernote' -gem 'evernote_oauth' - -# LocalFileAgent (watch functionality) -gem 'listen', '~> 3.0.5', require: false - -# S3Agent -gem 'aws-sdk-core', '~> 2.2.15' - -# Optional Services. -gem 'omniauth-37signals' # BasecampAgent -gem 'omniauth-wunderlist' - -# Bundler <1.5 does not recognize :x64_mingw as a valid platform name. -# Unfortunately, it can't self-update because it errors when encountering :x64_mingw. -unless Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.5.0') - STDERR.puts "Bundler >=1.5.0 is required. Please upgrade bundler with 'gem install bundler'" - exit 1 -end - -gem 'ace-rails-ap', '~> 2.0.1' -gem 'bootstrap-kaminari-views', '~> 0.0.3' -gem 'bundler', '>= 1.5.0' -gem 'coffee-rails', '~> 5' -gem 'daemons', '~> 1.1.9' -gem 'delayed_job', '~> 4.1.8' -gem 'delayed_job_active_record', github: 'dsander/delayed_job_active_record', branch: 'rails6-zeitwerk' -gem 'devise', '~> 4.7.1' -gem 'em-http-request', '~> 1.1.2' -gem 'faraday', '~> 0.9' -gem 'faraday_middleware', '~> 0.12.2' -gem 'feedjira', '~> 3.1' -gem 'font-awesome-sass', '~> 4.7.0' -gem 'foreman', '~> 0.63.0' -gem 'geokit', '~> 1.8.4' -gem 'geokit-rails', '~> 2.2.0' -gem 'httparty', '~> 0.13' -gem 'httmultiparty', '~> 0.3.16' -gem 'jquery-rails', '~> 4.2.1' -gem 'huginn_agent', '~> 0.4.0' -gem 'json', '~> 2.3' -gem 'jsonpath', '~> 1.0.1' -gem 'kaminari', '~> 1.1.1' -gem 'kramdown', '~> 1.3.3' -gem 'liquid', '~> 4.0.3' -gem 'loofah', '~> 2.0' -gem 'mini_magick', ">= 4.9.4" -gem 'multi_xml' -gem "nokogiri", ">= 1.10.8" -gem 'omniauth', '~> 1.6.1' -gem 'rails', '~> 6.0.3.1' -gem 'sprockets', '~> 3.7.2' -gem 'rails-html-sanitizer', '~> 1.2' -gem 'rufus-scheduler', '~> 3.4.2', require: false -gem 'sass-rails', '>= 6.0' -gem 'select2-rails', '~> 3.5.4' -gem 'spectrum-rails' -gem 'execjs', '~> 2.7.0' -gem 'typhoeus', '~> 1.3.1' -gem 'uglifier', '~> 2.7.2' -gem 'bootsnap', '~> 1.4.4', require: false - -group :development do - gem 'better_errors', '~> 1.1' - gem 'binding_of_caller', '~> 0.8.0' - gem 'guard', '~> 2.14.1' - gem 'guard-livereload', '~> 2.5.1' - gem 'guard-rspec', '~> 4.7.3' - gem 'rack-livereload', '~> 0.3.16' - gem 'letter_opener_web', '~> 1.3.1' - gem 'web-console', '>= 3.3.0' - - gem 'capistrano', '~> 3.11.0' - gem 'capistrano-rails', '~> 1.1' - gem 'capistrano-bundler', '~> 1.1.4' - - if_true(ENV['SPRING']) do - gem 'spring-commands-rspec', '~> 1.0.4' - gem 'spring', '~> 2.0.2' - gem 'spring-watcher-listen', '~> 2.0.1' - end - - group :test do - gem 'coveralls', '~> 0.8.23', require: false - gem 'capybara', '~> 2.18' - gem 'capybara-screenshot' - gem 'capybara-select-2', github: 'Hirurg103/capybara_select2', ref: 'fbf22fb74dec10fa0edcd26da7c5184ba8fa2c76', require: false - gem 'poltergeist' - gem 'pry-rails' - gem 'pry-byebug' - gem 'rr' - gem 'rspec', '~> 3.8' - gem 'rspec-rails' - gem 'rspec-collection_matchers', '~> 1.1.0' - gem 'rspec-html-matchers', '~> 0.8' - gem 'rails-controller-testing' - gem 'shoulda-matchers' - gem 'vcr' - gem 'webmock', '~> 3.5.1' - end -end - -group :production do - gem 'unicorn', '~> 5.1.0' -end - -# Platform requirements. -require 'rbconfig' -gem 'ffi', '>= 1.9.4' # required by typhoeus; 1.9.4 has fixes for *BSD. -gem 'tzinfo', '>= 1.2.0' # required by rails; 1.2.0 has support for *BSD and Solaris. -# Windows does not have zoneinfo files, so bundle the tzinfo-data gem. -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] -# BSD systems require rb-kqueue for "listen" to avoid polling for changes. -gem 'rb-kqueue', '>= 0.2', require: /bsd|dragonfly/i === RbConfig::CONFIG['target_os'] - - -on_heroku = ENV['ON_HEROKU'] || - ENV['HEROKU_POSTGRESQL_ROSE_URL'] || - ENV['HEROKU_POSTGRESQL_GOLD_URL'] || - File.read(File.join(File.dirname(__FILE__), 'Procfile')) =~ /intended for Heroku/ - -ENV['DATABASE_ADAPTER'] ||= - if on_heroku - 'postgresql' - else - 'mysql2' - end - -if_true(ENV['DATABASE_ADAPTER'].strip == 'postgresql') do - gem 'pg', '~> 1.1.3' -end - -if_true(ENV['DATABASE_ADAPTER'].strip == 'mysql2') do - gem 'mysql2' , "~> 0.5.2" -end - -GemfileHelper.parse_each_agent_gem(ENV['ADDITIONAL_GEMS']) do |args| - gem *args -end +source 'https://rubygems.org' + +ruby '>=2.5.0' + +# Ensure github repositories are fetched using HTTPS +git_source(:github) do |repo_name| + "https://github.com/#{repo_name}.git" +end + +# Load vendored dotenv gem and .env file +require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb') +GemfileHelper.load_dotenv do |dotenv_dir| + path dotenv_dir do + gem 'dotenv' + gem 'dotenv-rails' + end +end + +# Introduces a scope for gem loading based on a condition +def if_true(condition) + if condition + yield + else + # When not including the gems, we still want our Gemfile.lock + # to include them, so we scope them to an unsupported platform. + platform :ruby_18, &proc + end +end + +# Optional libraries. To conserve RAM, comment out any that you don't need, +# then run `bundle` and commit the updated Gemfile and Gemfile.lock. +gem 'twilio-ruby', '~> 3.11.5' # TwilioAgent +gem 'ruby-growl', '~> 4.1.0' # GrowlAgent +gem 'net-ftp-list', '~> 3.2.8' # FtpsiteAgent +gem 'forecast_io', '~> 2.0.0' # WeatherAgent +gem 'rturk', '~> 2.12.1' # HumanTaskAgent +gem 'erector', github: 'dsander/erector', branch: 'rails6' +gem 'hipchat', '~> 1.2.0' # HipchatAgent +gem 'mini_racer', '~> 0.2.4' # JavaScriptAgent +gem 'xmpp4r', '~> 0.5.6' # JabberAgent +gem 'mqtt' # MQTTAgent +gem 'slack-notifier', '~> 1.0.0' # SlackAgent +gem 'hypdf', '~> 1.0.10' # PDFInfoAgent + +# Weibo Agents +# FIXME needs to loosen omniauth dependency, add rest-client +gem 'weibo_2', github: 'albertsun/weibo_2', branch: 'master' + +# GoogleCalendarPublishAgent and GoogleTranslateAgent +gem 'google-api-client', '~> 0.13' +gem 'google-cloud-translate', '~> 1.0.0', require: 'google/cloud/translate' + +# Twitter Agents +gem 'twitter', github: 'sferik/twitter' # Must to be loaded before cantino-twitter-stream. +gem 'twitter-stream', github: 'cantino/twitter-stream', branch: 'huginn' +gem 'omniauth-twitter', '~> 1.3.0' + +# Tumblr Agents +# until merge of https://github.com/tumblr/tumblr_client/pull/61 +gem 'tumblr_client', github: 'albertsun/tumblr_client', branch: 'master', ref: 'e046fe6e39291c173add0a49081630c7b60a36c7' +gem 'omniauth-tumblr', '~> 1.2' + +# Dropbox Agents +gem 'dropbox-api', github: 'dsander/dropbox-api', ref: '86cb7b5a1254dc5b054de7263835713c4c1018c7' +gem 'omniauth-dropbox-oauth2', github: 'bamorim/omniauth-dropbox-oauth2', ref: '35046706fb781ed3b57dfb9c3cd44ed0f3d3f8ea' + +# UserLocationAgent +gem 'haversine' + +# EvernoteAgent +gem 'omniauth-evernote' +gem 'evernote_oauth' + +# LocalFileAgent (watch functionality) +gem 'listen', '~> 3.0.5', require: false + +# S3Agent +gem 'aws-sdk-core', '~> 2.2.15' + +# Optional Services. +gem 'omniauth-37signals' # BasecampAgent +gem 'omniauth-wunderlist' + +# Bundler <1.5 does not recognize :x64_mingw as a valid platform name. +# Unfortunately, it can't self-update because it errors when encountering :x64_mingw. +unless Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.5.0') + STDERR.puts "Bundler >=1.5.0 is required. Please upgrade bundler with 'gem install bundler'" + exit 1 +end + +gem 'ace-rails-ap', '~> 2.0.1' +gem 'bootstrap-kaminari-views', '~> 0.0.3' +gem 'bundler', '>= 1.5.0' +gem 'coffee-rails', '~> 5' +gem 'daemons', '~> 1.1.9' +gem 'delayed_job', '~> 4.1.8' +gem 'delayed_job_active_record', github: 'dsander/delayed_job_active_record', branch: 'rails6-zeitwerk' +gem 'devise', '~> 4.7.1' +gem 'em-http-request', '~> 1.1.2' +gem 'faraday', '~> 0.9' +gem 'faraday_middleware', '~> 0.12.2' +gem 'feedjira', '~> 3.1' +gem 'font-awesome-sass', '~> 4.7.0' +gem 'foreman', '~> 0.63.0' +gem 'geokit', '~> 1.8.4' +gem 'geokit-rails', '~> 2.2.0' +gem 'httparty', '~> 0.13' +gem 'httmultiparty', '~> 0.3.16' +gem 'jquery-rails', '~> 4.2.1' +gem 'huginn_agent', '~> 0.4.0' +gem 'json', '~> 2.3' +gem 'jsonpath', '~> 1.0.1' +gem 'kaminari', '~> 1.1.1' +gem 'kramdown', '~> 1.3.3' +gem 'liquid', '~> 4.0.3' +gem 'loofah', '~> 2.0' +gem 'mini_magick', ">= 4.9.4" +gem 'multi_xml' +gem "nokogiri", ">= 1.10.8" +gem 'omniauth', '~> 1.6.1' +gem 'rails', '~> 6.0.3.6' +gem 'sprockets', '~> 3.7.2' +gem 'rails-html-sanitizer', '~> 1.2' +gem 'rufus-scheduler', '~> 3.4.2', require: false +gem 'sass-rails', '>= 6.0' +gem 'select2-rails', '~> 3.5.4' +gem 'spectrum-rails' +gem 'execjs', '~> 2.7.0' +gem 'typhoeus', '~> 1.3.1' +gem 'uglifier', '~> 2.7.2' +gem 'bootsnap', '~> 1.4.4', require: false + +group :development do + gem 'better_errors', '~> 1.1' + gem 'binding_of_caller', '~> 0.8.0' + gem 'guard', '~> 2.14.1' + gem 'guard-livereload', '~> 2.5.1' + gem 'guard-rspec', '~> 4.7.3' + gem 'rack-livereload', '~> 0.3.16' + gem 'letter_opener_web', '~> 1.3.1' + gem 'web-console', '>= 3.3.0' + + gem 'capistrano', '~> 3.11.0' + gem 'capistrano-rails', '~> 1.1' + gem 'capistrano-bundler', '~> 1.1.4' + + if_true(ENV['SPRING']) do + gem 'spring-commands-rspec', '~> 1.0.4' + gem 'spring', '~> 2.0.2' + gem 'spring-watcher-listen', '~> 2.0.1' + end + + group :test do + gem 'coveralls', '~> 0.8.23', require: false + gem 'capybara', '~> 2.18' + gem 'capybara-screenshot' + gem 'capybara-select-2', github: 'Hirurg103/capybara_select2', ref: 'fbf22fb74dec10fa0edcd26da7c5184ba8fa2c76', require: false + gem 'poltergeist' + gem 'pry-rails' + gem 'pry-byebug' + gem 'rr' + gem 'rspec', '~> 3.8' + gem 'rspec-rails' + gem 'rspec-collection_matchers', '~> 1.1.0' + gem 'rspec-html-matchers', '~> 0.8' + gem 'rails-controller-testing' + gem 'shoulda-matchers' + gem 'vcr' + gem 'webmock', '~> 3.5.1' + end +end + +group :production do + gem 'unicorn', '~> 5.1.0' +end + +# Platform requirements. +require 'rbconfig' +gem 'ffi', '>= 1.9.4' # required by typhoeus; 1.9.4 has fixes for *BSD. +gem 'tzinfo', '>= 1.2.0' # required by rails; 1.2.0 has support for *BSD and Solaris. +# Windows does not have zoneinfo files, so bundle the tzinfo-data gem. +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] +# BSD systems require rb-kqueue for "listen" to avoid polling for changes. +gem 'rb-kqueue', '>= 0.2', require: /bsd|dragonfly/i === RbConfig::CONFIG['target_os'] + + +on_heroku = ENV['ON_HEROKU'] || + ENV['HEROKU_POSTGRESQL_ROSE_URL'] || + ENV['HEROKU_POSTGRESQL_GOLD_URL'] || + File.read(File.join(File.dirname(__FILE__), 'Procfile')) =~ /intended for Heroku/ + +ENV['DATABASE_ADAPTER'] ||= + if on_heroku + 'postgresql' + else + 'mysql2' + end + +if_true(ENV['DATABASE_ADAPTER'].strip == 'postgresql') do + gem 'pg', '~> 1.1.3' +end + +if_true(ENV['DATABASE_ADAPTER'].strip == 'mysql2') do + gem 'mysql2' , "~> 0.5.2" +end + +GemfileHelper.parse_each_agent_gem(ENV['ADDITIONAL_GEMS']) do |args| + gem *args +end diff --git a/Gemfile.lock b/Gemfile.lock index 75374457b3..71644fd8bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,56 +102,56 @@ GEM remote: https://rubygems.org/ specs: ace-rails-ap (2.0.1) - actioncable (6.0.3.1) - actionpack (= 6.0.3.1) + actioncable (6.0.3.6) + actionpack (= 6.0.3.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.1) - actionpack (= 6.0.3.1) - activejob (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) + actionmailbox (6.0.3.6) + actionpack (= 6.0.3.6) + activejob (= 6.0.3.6) + activerecord (= 6.0.3.6) + activestorage (= 6.0.3.6) + activesupport (= 6.0.3.6) mail (>= 2.7.1) - actionmailer (6.0.3.1) - actionpack (= 6.0.3.1) - actionview (= 6.0.3.1) - activejob (= 6.0.3.1) + actionmailer (6.0.3.6) + actionpack (= 6.0.3.6) + actionview (= 6.0.3.6) + activejob (= 6.0.3.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.1) - actionview (= 6.0.3.1) - activesupport (= 6.0.3.1) + actionpack (6.0.3.6) + actionview (= 6.0.3.6) + activesupport (= 6.0.3.6) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.1) - actionpack (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) + actiontext (6.0.3.6) + actionpack (= 6.0.3.6) + activerecord (= 6.0.3.6) + activestorage (= 6.0.3.6) + activesupport (= 6.0.3.6) nokogiri (>= 1.8.5) - actionview (6.0.3.1) - activesupport (= 6.0.3.1) + actionview (6.0.3.6) + activesupport (= 6.0.3.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.3.1) - activesupport (= 6.0.3.1) + activejob (6.0.3.6) + activesupport (= 6.0.3.6) globalid (>= 0.3.6) - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activestorage (6.0.3.1) - actionpack (= 6.0.3.1) - activejob (= 6.0.3.1) - activerecord (= 6.0.3.1) - marcel (~> 0.3.1) - activesupport (6.0.3.1) + activemodel (6.0.3.6) + activesupport (= 6.0.3.6) + activerecord (6.0.3.6) + activemodel (= 6.0.3.6) + activesupport (= 6.0.3.6) + activestorage (6.0.3.6) + actionpack (= 6.0.3.6) + activejob (= 6.0.3.6) + activerecord (= 6.0.3.6) + marcel (~> 1.0.0) + activesupport (6.0.3.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -207,7 +207,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.6) + concurrent-ruby (1.1.8) cookiejar (0.3.2) coveralls (0.8.23) json (>= 1.8, < 3) @@ -246,7 +246,7 @@ GEM eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) equalizer (0.0.11) - erubi (1.9.0) + erubi (1.10.0) erubis (2.7.0) et-orbi (1.0.9) tzinfo @@ -351,7 +351,7 @@ GEM hypdf (1.0.10) httmultiparty (~> 0.3) httparty (~> 0.13) - i18n (1.8.2) + i18n (1.8.10) concurrent-ruby (~> 1.0) jmespath (1.1.3) jquery-rails (4.2.2) @@ -394,7 +394,7 @@ GEM logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - loofah (2.5.0) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.12) @@ -402,8 +402,7 @@ GEM systemu (~> 2.6.2) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) memoist (0.16.0) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) @@ -411,13 +410,15 @@ GEM mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mimemagic (0.3.5) + mimemagic (0.4.3) + nokogiri (~> 1) + rake mini_magick (4.9.5) - mini_mime (1.0.2) - mini_portile2 (2.4.0) + mini_mime (1.1.0) + mini_portile2 (2.5.0) mini_racer (0.2.9) libv8 (>= 6.9.411) - minitest (5.14.1) + minitest (5.14.4) mqtt (0.3.1) msgpack (1.3.1) multi_json (1.13.1) @@ -431,9 +432,10 @@ GEM net-ssh (>= 2.6.5) net-ssh (5.0.2) netrc (0.11.0) - nio4r (2.5.2) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) + nio4r (2.5.7) + nokogiri (1.11.2) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) @@ -487,25 +489,26 @@ GEM pry-rails (0.3.4) pry (>= 0.9.10) public_suffix (3.0.2) - rack (2.2.2) + racc (1.5.2) + rack (2.2.3) rack-livereload (0.3.16) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.1) - actioncable (= 6.0.3.1) - actionmailbox (= 6.0.3.1) - actionmailer (= 6.0.3.1) - actionpack (= 6.0.3.1) - actiontext (= 6.0.3.1) - actionview (= 6.0.3.1) - activejob (= 6.0.3.1) - activemodel (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) + rails (6.0.3.6) + actioncable (= 6.0.3.6) + actionmailbox (= 6.0.3.6) + actionmailer (= 6.0.3.6) + actionpack (= 6.0.3.6) + actiontext (= 6.0.3.6) + actionview (= 6.0.3.6) + activejob (= 6.0.3.6) + activemodel (= 6.0.3.6) + activerecord (= 6.0.3.6) + activestorage (= 6.0.3.6) + activesupport (= 6.0.3.6) bundler (>= 1.3.0) - railties (= 6.0.3.1) + railties (= 6.0.3.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) @@ -516,14 +519,14 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.0.3.1) - actionpack (= 6.0.3.1) - activesupport (= 6.0.3.1) + railties (6.0.3.6) + actionpack (= 6.0.3.6) + activesupport (= 6.0.3.6) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) raindrops (0.17.0) - rake (13.0.1) + rake (13.0.3) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) @@ -622,7 +625,7 @@ GEM sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -645,7 +648,7 @@ GEM multi_json (>= 1.3.0) typhoeus (1.3.1) ethon (>= 0.9.0) - tzinfo (1.2.7) + tzinfo (1.2.9) thread_safe (~> 0.1) uber (0.1.0) uglifier (2.7.2) @@ -671,13 +674,13 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket-driver (0.7.2) + websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.4) + websocket-extensions (0.1.5) xmpp4r (0.5.6) xpath (3.0.0) nokogiri (~> 1.8) - zeitwerk (2.3.0) + zeitwerk (2.4.2) PLATFORMS ruby @@ -757,7 +760,7 @@ DEPENDENCIES pry-byebug pry-rails rack-livereload (~> 0.3.16) - rails (~> 6.0.3.1) + rails (~> 6.0.3.6) rails-controller-testing rails-html-sanitizer (~> 1.2) rb-kqueue (>= 0.2) diff --git a/config/application.rb b/config/application.rb index 094aec2f1e..f54b05b41a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,51 +1,52 @@ -require_relative 'boot' - -require 'rails/all' - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module Huginn - class Application < Rails::Application - Dotenv.overload File.expand_path('../../spec/env.test', __FILE__) if Rails.env.test? - - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 - - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. - - # Custom directories with classes and modules you want to be autoloadable. - config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/presenters #{config.root}/app/jobs) - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - config.time_zone = ENV['TIMEZONE'].presence || "Pacific Time (US & Canada)" - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Enable escaping HTML in JSON. - config.active_support.escape_html_entities_in_json = true - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - config.active_job.queue_adapter = :delayed_job - - config.action_view.sanitized_allowed_tags = %w[strong em b i p code pre tt samp kbd var sub sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dl dt dd abbr acronym a img blockquote del ins style table thead tbody tr th td] - config.action_view.sanitized_allowed_attributes = %w[href src width height alt cite datetime title class name xml:lang abbr border cellspacing cellpadding valign style] - end -end +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Huginn + class Application < Rails::Application + Dotenv.overload File.expand_path('../../spec/env.test', __FILE__) if Rails.env.test? + + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 6.0 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Custom directories with classes and modules you want to be autoloadable. + config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/presenters #{config.root}/app/jobs) + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + config.time_zone = ENV['TIMEZONE'].presence || "Pacific Time (US & Canada)" + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Enable escaping HTML in JSON. + config.active_support.escape_html_entities_in_json = true + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + config.active_job.queue_adapter = :delayed_job + + config.action_view.sanitized_allowed_tags = %w[strong em b i p code pre tt samp kbd var sub sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dl dt dd abbr acronym a img blockquote del ins style table thead tbody tr th td] + config.action_view.sanitized_allowed_attributes = %w[href src width height alt cite datetime title class name xml:lang abbr border cellspacing cellpadding valign style] + config.autoloader = :classic + end +end diff --git a/docker/scripts/prepare b/docker/scripts/prepare index a657cadf1b..de11865269 100755 --- a/docker/scripts/prepare +++ b/docker/scripts/prepare @@ -18,6 +18,7 @@ export DEBIAN_FRONTEND=noninteractive CLEAR_DOCKER_CACHE=2020-05-28 +echo $'\nInstall packages' minimal_apt_get_install='apt-get install -y --no-install-recommends' apt-get update @@ -34,6 +35,10 @@ locale-gen en_US.UTF-8 update-locale LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 gem install --no-document bundler -v 1.17.3 +echo $'\nInstall shared-mime-info' +apt-get install shared-mime-info + +echo $'\nPurge python3* rsyslog rsync manpages' apt-get purge -y python3* rsyslog rsync manpages apt-get -y clean apt-get -y autoremove @@ -44,8 +49,10 @@ rm -rf /usr/share/locale/ rm -rf /var/log/* # Install the latest jq for JqAgent +echo $'\nInstall the latest jq for JqAgent' curl -fsSL -o /usr/local/bin/jq https://github.com/stedolan/jq/releases/latest/download/jq-linux64 chmod +x /usr/local/bin/jq mkdir -p /app chmod -R g=u /etc/passwd /app +echo $'\nFinished Docker Prepare Script\n' diff --git a/docker/scripts/setup_env b/docker/scripts/setup_env index b67bf4b328..812f2d16a9 100755 --- a/docker/scripts/setup_env +++ b/docker/scripts/setup_env @@ -1,4 +1,5 @@ #!/bin/bash +echo "Setting up environment" set -e export LC_ALL=en_US.UTF-8 @@ -47,10 +48,18 @@ PORT=${HUGINN_PORT:-${PORT:-3000}} PORT="$(echo $PORT|awk -F ':' '{print $NF}')" HUGINN_PORT=${PORT} -cp -a /app/.env.example /tmp/ +# Copy .env file to /tmp +if [ -f "/app/.env.custom" ]; then + echo "Using .env.custom environment file" + cp -a /app/.env.custom /tmp/.env.example +else + echo "Using .env.example environment file" + cp -a /app/.env.example /tmp/.env.example +fi # Do we have a Rails secret yet? # If not, generate one, but persist it for the container's lifetime. +echo "Checking for Rails secret" if [ -z "$APP_SECRET_TOKEN" ] && grep -q ^APP_SECRET_TOKEN=REPLACE_ME_NOW /tmp/.env.example; then [ -e '/tmp/secret' ] && secret="$(cat /tmp/secret)" if [ -z "$secret" ]; then @@ -62,6 +71,7 @@ if [ -z "$APP_SECRET_TOKEN" ] && grep -q ^APP_SECRET_TOKEN=REPLACE_ME_NOW /tmp/. fi # Add ENV variables to .env.example which are not present in it but usable +echo "Add ENV variables to .env.example which are not present in it but usable" cat >> /tmp/.env.example <> /tmp/.env.example +# Copying /app/.env to /tmp/.env.example if .env exists +if [ -e '/app/.env' ]; then + echo "Copying /app/.env to /tmp/.env.example" + cat /app/.env >> /tmp/.env.example +fi +# function quote_if_necessary quote_if_necessary() { if grep -q -E -e '^".*" *$' -e "^'.*' *$" <<<"$*"; then # preserve single or double quotes if they are provided @@ -91,15 +106,32 @@ quote_if_necessary() { } # Default to the environment variable values set in .env.example +echo "Default to the environment variable values set in .env.example" sed -n -r -e 's/^#?([A-Za-z0-9_]+=.*)/\1/p' /tmp/.env.example | \ while IFS='=' read var value ; do - huginn_var="HUGINN_$var" + huginn_var="HUGINN_$var" val="${!huginn_var:-${!var:-$value}}" echo "$var=$(quote_if_necessary $val)" done > /tmp/.env +# Checking if /tmp/.env exists +if [ -e "/tmp/.env" ]; then + echo "Found /tmp/.env" +else + echo "Not found /tmp/.env" +fi + +# Output /tmp/.env file (for debugging) +echo "Output /tmp/.env file (for debugging)" +echo "---" +cat /tmp/.env +echo "---" + +# Run /tmp/.env in current shell environment +echo "Running 'source /tmp/.env'" source /tmp/.env + if [ "${START_MYSQL}" = "true" ]; then echo 'DATABASE_SOCKET=/app/tmp/sockets/mysqld.sock' >> /tmp/.env DATABASE_SOCKET='/app/tmp/sockets/mysqld.sock' @@ -110,15 +142,18 @@ chmod ugo+r /app/.env rm -f /tmp/.env.example # use default port number if it is still not set +echo "Use default port number if it is still not set" case "${DATABASE_ADAPTER}" in mysql2) DATABASE_PORT=${DATABASE_PORT:-3306} ;; postgresql) DATABASE_PORT=${DATABASE_PORT:-5432} ;; *) echo "Unsupported database adapter. Available adapters are mysql2, and postgresql." && exit 1 ;; esac +echo "Running bundle install" bundle install --without test development --path vendor/bundle -# Configure the unicorn server +# Configuring the unicorn server +echo "Configuring the unicorn server" sed -r config/unicorn.rb.example \ -e "s/^ *listen .+/listen '$IP:$PORT'/" \ -e 's;^ *stderr_path .+;stderr_path "/dev/stderr";' \ @@ -126,3 +161,5 @@ sed -r config/unicorn.rb.example \ -e '/^ *pid .+/d' > config/unicorn.rb mkdir -p tmp/pids tmp/cache tmp/sockets log + +echo "Finished setup_env" \ No newline at end of file