From 41ccdd79378dfd6df2af99ae8e9b9e44a07c0376 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:50:31 +0200 Subject: [PATCH 01/45] Regenerate app with: bundle exec rails new . \ --database=postgresql \ --skip-action-mailer \ --skip-action-mailbox \ --skip-action-text \ --skip-active-job \ --skip-action-cable \ --skip-asset-pipeline \ --skip-javascript \ --skip-hotwire \ --skip-jbuilder \ --skip-test \ --skip-system-test --- Gemfile | 51 +++++---- Gemfile.lock | 315 ++++++++++++++++++--------------------------------- 2 files changed, 140 insertions(+), 226 deletions(-) diff --git a/Gemfile b/Gemfile index 21d312b0..8c3b2c81 100644 --- a/Gemfile +++ b/Gemfile @@ -1,37 +1,42 @@ -# frozen_string_literal: true - source "https://rubygems.org" -ruby File.read(".ruby-version") +ruby "3.2.2" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 7.1.1" + +# Use postgresql as the database for Active Record +gem "pg", "~> 1.1" -gem "rails", "7.0.8" -gem "pg" -gem "puma" +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", ">= 5.0" + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem "kredis" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem "tzinfo-data", platforms: %i[ windows jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false -gem "rails-pg-extras" -gem "pry-rails" -gem "sshkit", require: false - -gem "uri", ">= 0.12.2" - group :development, :test do - gem "dotenv-rails" - gem "rspec-rails", ">= 6.0.1" + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri windows ] end group :development do - gem "license_finder", require: false - gem "rubocop", require: false - gem "rubocop-disable_syntax", require: false - gem "rubocop-performance", require: false - gem "rubocop-rails", require: false - gem "standard", "1.31.2", require: false - gem "brakeman", require: false - gem "fasterer", require: false + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" + + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + # gem "rack-mini-profiler" + + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + # gem "spring" + end + diff --git a/Gemfile.lock b/Gemfile.lock index b787f2c6..5a43d13f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,105 +1,103 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.1) + actionpack (= 7.1.1) + activesupport (= 7.1.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.1) + actionpack (= 7.1.1) + activejob (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.1) + actionpack (= 7.1.1) + actionview (= 7.1.1) + activejob (= 7.1.1) + activesupport (= 7.1.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.1) + actionview (= 7.1.1) + activesupport (= 7.1.1) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.1) + actionpack (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.1) + activesupport (= 7.1.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.1) + activesupport (= 7.1.1) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.1) + activesupport (= 7.1.1) + activerecord (7.1.1) + activemodel (= 7.1.1) + activesupport (= 7.1.1) + timeout (>= 0.4.0) + activestorage (7.1.1) + actionpack (= 7.1.1) + activejob (= 7.1.1) + activerecord (= 7.1.1) + activesupport (= 7.1.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.1) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - ast (2.4.2) base64 (0.1.1) + bigdecimal (3.1.4) + bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) - brakeman (6.0.1) builder (3.2.4) - coderay (1.1.3) - colorize (0.8.1) concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) date (3.3.3) - diff-lcs (1.5.0) - dotenv (2.8.1) - dotenv-rails (2.8.1) - dotenv (= 2.8.1) - railties (>= 3.2) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + drb (2.1.1) + ruby2_keywords erubi (1.12.0) - fasterer (0.10.1) - colorize (~> 0.7) - ruby_parser (>= 3.19.1) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) - json (2.6.3) - language_server-protocol (3.17.0.3) - license_finder (7.1.0) - bundler - rubyzip (>= 1, < 3) - thor (~> 1.2) - tomlrb (>= 1.3, < 2.1) - with_env (= 1.1.0) - xml-simple (~> 1.1.9) - lint_roller (1.1.0) + io-console (0.6.0) + irb (1.8.3) + rdoc + reline (>= 0.3.8) loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -109,11 +107,10 @@ GEM net-pop net-smtp marcel (1.0.2) - method_source (1.0.0) mini_mime (1.1.5) - mini_portile2 (2.8.4) minitest (5.20.0) msgpack (1.7.2) + mutex_m (0.1.2) net-imap (0.4.1) date net-protocol @@ -121,53 +118,43 @@ GEM net-protocol net-protocol (0.2.1) timeout - net-scp (4.0.0) - net-ssh (>= 2.6.5, < 8.0.0) net-smtp (0.4.0) net-protocol - net-ssh (7.2.0) nio4r (2.5.9) - nokogiri (1.15.4) - mini_portile2 (~> 2.8.2) - racc (~> 1.4) nokogiri (1.15.4-aarch64-linux) racc (~> 1.4) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.4-x86_64-darwin) - racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.4) - ast (~> 2.4.1) - racc pg (1.5.4) - pry (0.14.2) - coderay (~> 1.1) - method_source (~> 1.0) - pry-rails (0.3.9) - pry (>= 0.10.4) + psych (5.1.1) + stringio puma (6.4.0) nio4r (~> 2.0) racc (1.7.1) - rack (2.2.8) + rack (3.0.8) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.1) + actioncable (= 7.1.1) + actionmailbox (= 7.1.1) + actionmailer (= 7.1.1) + actionpack (= 7.1.1) + actiontext (= 7.1.1) + actionview (= 7.1.1) + activejob (= 7.1.1) + activemodel (= 7.1.1) + activerecord (= 7.1.1) + activestorage (= 7.1.1) + activesupport (= 7.1.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -175,127 +162,49 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-pg-extras (5.3.0) - rails - ruby-pg-extras (= 5.3.0) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.1) + actionpack (= 7.1.1) + activesupport (= 7.1.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rainbow (3.1.1) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rake (13.0.6) - regexp_parser (2.8.2) - rexml (3.2.6) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.0.3) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.1) - rubocop (1.56.4) - base64 (~> 0.1.1) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.2.2.3) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - rubocop-disable_syntax (0.1.1) - rubocop (>= 1.50) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.21.2) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - ruby-pg-extras (5.3.0) - pg - terminal-table - ruby-progressbar (1.13.0) - ruby_parser (3.20.3) - sexp_processor (~> 4.16) - rubyzip (2.3.2) - sexp_processor (4.17.0) - sshkit (1.21.5) - net-scp (>= 1.1.2) - net-ssh (>= 2.8.0) - standard (1.31.2) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.56.4) - standard-custom (~> 1.0.0) - standard-performance (~> 1.2) - standard-custom (1.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.50) - standard-performance (1.2.1) - lint_roller (~> 1.1) - rubocop-performance (~> 1.19.1) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) + rdoc (6.5.0) + psych (>= 4.0.0) + reline (0.3.9) + io-console (~> 0.5) + ruby2_keywords (0.0.5) + stringio (3.0.8) thor (1.2.2) timeout (0.4.0) - tomlrb (2.0.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - uri (0.12.2) + web-console (4.2.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - with_env (1.1.0) - xml-simple (1.1.9) - rexml zeitwerk (2.6.12) PLATFORMS aarch64-linux - arm64-darwin - ruby - x86_64-darwin + arm64-darwin-22 x86_64-linux DEPENDENCIES bootsnap - brakeman - dotenv-rails - fasterer - license_finder - pg - pry-rails - puma - rails (= 7.0.8) - rails-pg-extras - rspec-rails (>= 6.0.1) - rubocop - rubocop-disable_syntax - rubocop-performance - rubocop-rails - sshkit - standard (= 1.31.2) + debug + pg (~> 1.1) + puma (>= 5.0) + rails (~> 7.1.1) tzinfo-data - uri (>= 0.12.2) + web-console RUBY VERSION ruby 3.2.2p53 From 075252add6a0079352551228b304ed74d2618744 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:53:16 +0200 Subject: [PATCH 02/45] Cleanup --- Gemfile | 35 +++++++---------------------------- Gemfile.lock | 17 +++-------------- 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/Gemfile b/Gemfile index 8c3b2c81..67f3d4b9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,42 +1,21 @@ -source "https://rubygems.org" - -ruby "3.2.2" - -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.1.1" +# frozen_string_literal: true -# Use postgresql as the database for Active Record -gem "pg", "~> 1.1" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" +source "https://rubygems.org" -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" +ruby file: ".ruby-version" -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" +gem "rails", "7.1.1" +gem "pg" +gem "puma" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] +gem "tzinfo-data", platforms: [:windows, :jruby] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ] end group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" - - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" - end - diff --git a/Gemfile.lock b/Gemfile.lock index 5a43d13f..2627919a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,7 +76,6 @@ GEM tzinfo (~> 2.0) base64 (0.1.1) bigdecimal (3.1.4) - bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) @@ -84,9 +83,6 @@ GEM connection_pool (2.4.1) crass (1.0.6) date (3.3.3) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) drb (2.1.1) ruby2_keywords erubi (1.12.0) @@ -181,11 +177,6 @@ GEM timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -199,12 +190,10 @@ PLATFORMS DEPENDENCIES bootsnap - debug - pg (~> 1.1) - puma (>= 5.0) - rails (~> 7.1.1) + pg + puma + rails (= 7.1.1) tzinfo-data - web-console RUBY VERSION ruby 3.2.2p53 From d7e12cb67a61afcca5febf79b4b9d8e5909aefc7 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:53:52 +0200 Subject: [PATCH 03/45] Update --- Gemfile | 16 +++++++ Gemfile.lock | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/Gemfile b/Gemfile index 67f3d4b9..a53df5b2 100644 --- a/Gemfile +++ b/Gemfile @@ -14,8 +14,24 @@ gem "tzinfo-data", platforms: [:windows, :jruby] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false +gem "rails-pg-extras" +gem "pry-rails" +gem "sshkit", require: false + +gem "uri", ">= 0.12.2" + group :development, :test do + gem "dotenv-rails" + gem "rspec-rails", ">= 6.0.1" end group :development do + gem "license_finder", require: false + gem "rubocop", require: false + gem "rubocop-disable_syntax", require: false + gem "rubocop-performance", require: false + gem "rubocop-rails", require: false + gem "standard", "1.31.2", require: false + gem "brakeman", require: false + gem "fasterer", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 2627919a..1ca10c7a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,18 +74,30 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) + ast (2.4.2) base64 (0.1.1) bigdecimal (3.1.4) bootsnap (1.16.0) msgpack (~> 1.2) + brakeman (6.0.1) builder (3.2.4) + coderay (1.1.3) + colorize (0.8.1) concurrent-ruby (1.2.2) connection_pool (2.4.1) crass (1.0.6) date (3.3.3) + diff-lcs (1.5.0) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) + railties (>= 3.2) drb (2.1.1) ruby2_keywords erubi (1.12.0) + fasterer (0.10.1) + colorize (~> 0.7) + ruby_parser (>= 3.19.1) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.1) @@ -94,6 +106,16 @@ GEM irb (1.8.3) rdoc reline (>= 0.3.8) + json (2.6.3) + language_server-protocol (3.17.0.3) + license_finder (7.1.0) + bundler + rubyzip (>= 1, < 3) + thor (~> 1.2) + tomlrb (>= 1.3, < 2.1) + with_env (= 1.1.0) + xml-simple (~> 1.1.9) + lint_roller (1.1.0) loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -103,6 +125,7 @@ GEM net-pop net-smtp marcel (1.0.2) + method_source (1.0.0) mini_mime (1.1.5) minitest (5.20.0) msgpack (1.7.2) @@ -114,8 +137,11 @@ GEM net-protocol net-protocol (0.2.1) timeout + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) net-smtp (0.4.0) net-protocol + net-ssh (7.2.0) nio4r (2.5.9) nokogiri (1.15.4-aarch64-linux) racc (~> 1.4) @@ -123,7 +149,16 @@ GEM racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) + parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc pg (1.5.4) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) psych (5.1.1) stringio puma (6.4.0) @@ -158,6 +193,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) + rails-pg-extras (5.3.0) + rails + ruby-pg-extras (= 5.3.0) railties (7.1.1) actionpack (= 7.1.1) activesupport (= 7.1.1) @@ -166,21 +204,95 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) + rainbow (3.1.1) rake (13.0.6) rdoc (6.5.0) psych (>= 4.0.0) + regexp_parser (2.8.2) reline (0.3.9) io-console (~> 0.5) + rexml (3.2.6) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-rails (6.0.3) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) + rspec-support (3.12.1) + rubocop (1.56.4) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-disable_syntax (0.1.1) + rubocop (>= 1.50) + rubocop-performance (1.19.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.21.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + ruby-pg-extras (5.3.0) + pg + terminal-table + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + ruby_parser (3.20.3) + sexp_processor (~> 4.16) + rubyzip (2.3.2) + sexp_processor (4.17.0) + sshkit (1.21.5) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + standard (1.31.2) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.56.4) + standard-custom (~> 1.0.0) + standard-performance (~> 1.2) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.2.1) + lint_roller (~> 1.1) + rubocop-performance (~> 1.19.1) stringio (3.0.8) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) thor (1.2.2) timeout (0.4.0) + tomlrb (2.0.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) + uri (0.12.2) webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + with_env (1.1.0) + xml-simple (1.1.9) + rexml zeitwerk (2.6.12) PLATFORMS @@ -190,10 +302,24 @@ PLATFORMS DEPENDENCIES bootsnap + brakeman + dotenv-rails + fasterer + license_finder pg + pry-rails puma rails (= 7.1.1) + rails-pg-extras + rspec-rails (>= 6.0.1) + rubocop + rubocop-disable_syntax + rubocop-performance + rubocop-rails + sshkit + standard (= 1.31.2) tzinfo-data + uri (>= 0.12.2) RUBY VERSION ruby 3.2.2p53 From 7e39ce5cb259ba1e434cd12b4f667fbc9bedb62a Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:55:10 +0200 Subject: [PATCH 04/45] Update --- Gemfile.lock | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1ca10c7a..06343fd3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -127,6 +127,7 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) + mini_portile2 (2.8.4) minitest (5.20.0) msgpack (1.7.2) mutex_m (0.1.2) @@ -143,10 +144,15 @@ GEM net-protocol net-ssh (7.2.0) nio4r (2.5.9) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) nokogiri (1.15.4-aarch64-linux) racc (~> 1.4) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.4-x86_64-darwin) + racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) parallel (1.23.0) @@ -297,7 +303,9 @@ GEM PLATFORMS aarch64-linux - arm64-darwin-22 + arm64-darwin + ruby + x86_64-darwin x86_64-linux DEPENDENCIES From 295f5d68bda604b2c7ac5ad017a52d23f75b70cf Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:58:28 +0200 Subject: [PATCH 05/45] Update --- bin/bundle | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/bin/bundle b/bin/bundle index 5b593cb6..42c7fd7c 100755 --- a/bin/bundle +++ b/bin/bundle @@ -41,13 +41,13 @@ m = Module.new do gemfile = ENV["BUNDLE_GEMFILE"] return gemfile if gemfile && !gemfile.empty? - File.expand_path("../../Gemfile", __FILE__) + File.expand_path("../Gemfile", __dir__) end def lockfile lockfile = case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") else "#{gemfile}.lock" end File.expand_path(lockfile) @@ -62,8 +62,9 @@ m = Module.new do def bundler_requirement @bundler_requirement ||= - env_var_version || cli_arg_version || - bundler_requirement_for(lockfile_version) + env_var_version || + cli_arg_version || + bundler_requirement_for(lockfile_version) end def bundler_requirement_for(version) @@ -71,13 +72,7 @@ m = Module.new do bundler_gem_version = Gem::Version.new(version) - requirement = bundler_gem_version.approximate_recommendation - - return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0") - - requirement += ".a" if bundler_gem_version.prerelease? - - requirement + bundler_gem_version.approximate_recommendation end def load_bundler! From c76009411bcf033e01dc25fd08f97f019d1eb4e7 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 20:58:48 +0200 Subject: [PATCH 06/45] Update --- bin/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setup b/bin/setup index ec47b79b..3cd5a9d7 100755 --- a/bin/setup +++ b/bin/setup @@ -5,7 +5,7 @@ require "fileutils" APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do From 11b630fe4b336aa4037938e4c040995f279cf970 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:02:44 +0200 Subject: [PATCH 07/45] Update --- .env.example | 2 -- 1 file changed, 2 deletions(-) diff --git a/.env.example b/.env.example index a1781966..100c0f89 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,4 @@ SECRET_KEY_BASE= -RAILS_SERVE_STATIC_FILES=yes -RAILS_LOG_TO_STDOUT=yes RAILS_MAX_THREADS=2 RAILS_MIN_THREADS=2 DATABASE_URL="postgres://user:password@localhost/database" From bb1a88cca4d0b79036b4ec312173d159dc6b6e0e Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:04:05 +0200 Subject: [PATCH 08/45] Update --- db/seeds.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 65333264..0f162112 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,9 +1,11 @@ # frozen_string_literal: true -# This file should contain all the record creation needed to seed the database with its default values. +# This file should ensure the existence of records required to run the application in every environment (production, +# development, test). The code here should be idempotent so that it can be executed at any point in every environment. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # -# Examples: +# Example: # -# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) -# Character.create(name: "Luke", movie: movies.first) +# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| +# MovieGenre.find_or_create_by!(name: genre_name) +# end From 99a9cf5798b14620e8e76f0cfe0c7c20677713ce Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:05:17 +0200 Subject: [PATCH 09/45] Update --- config/initializers/permissions_policy.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 810aadeb..e8d0b2ae 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,13 +1,15 @@ # frozen_string_literal: true +# Be sure to restart your server when you modify this file. + # Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" # end From 8a58633a82e286618291e9e04d5baa8341e0edfb Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:06:47 +0200 Subject: [PATCH 10/45] Update --- bin/rubocop | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/rubocop b/bin/rubocop index d0c48829..369a05be 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -8,14 +8,12 @@ # this file is here to facilitate running it. # -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -bundle_binstub = File.expand_path("../bundle", __FILE__) +bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. From 20dd8c03cde5f0f5dee11a4a730b8cfae9c19c61 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:07:57 +0200 Subject: [PATCH 11/45] Update --- bin/standardrb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/standardrb b/bin/standardrb index 6fc2e1a7..b329561c 100755 --- a/bin/standardrb +++ b/bin/standardrb @@ -8,14 +8,12 @@ # this file is here to facilitate running it. # -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -bundle_binstub = File.expand_path("../bundle", __FILE__) +bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. From 267df6aaaeb2ff3b13e898a4189237940fb53a0c Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:09:40 +0200 Subject: [PATCH 12/45] Add bin/docker-entrypoint --- bin/docker-entrypoint | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 bin/docker-entrypoint diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint new file mode 100755 index 00000000..67ef4931 --- /dev/null +++ b/bin/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# If running the rails server then create or migrate existing database +if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then + ./bin/rails db:prepare +fi + +exec "${@}" From f9464d955030c1b80c4a661755f438a169ddaa58 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:22:52 +0200 Subject: [PATCH 13/45] Update --- bin/license_finder | 8 +++----- bin/license_finder_pip.py | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/license_finder b/bin/license_finder index e7898b6a..16934121 100755 --- a/bin/license_finder +++ b/bin/license_finder @@ -8,14 +8,12 @@ # this file is here to facilitate running it. # -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -bundle_binstub = File.expand_path("../bundle", __FILE__) +bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. diff --git a/bin/license_finder_pip.py b/bin/license_finder_pip.py index e37e6d2b..c5d7d88f 100755 --- a/bin/license_finder_pip.py +++ b/bin/license_finder_pip.py @@ -8,14 +8,12 @@ # this file is here to facilitate running it. # -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -bundle_binstub = File.expand_path("../bundle", __FILE__) +bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. From c7adb676be7e4ef59233f114e3a99b0ecb49d643 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:26:19 +0200 Subject: [PATCH 14/45] Update postgres to 16.0 --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 0710883a..3e8dedf6 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -24,7 +24,7 @@ jobs: services: postgres: - image: "postgres:15.3" + image: "postgres:16.0" env: POSTGRES_HOST_AUTH_METHOD: "trust" POSTGRES_USER: "runner" From 795fa3a9911b22d6e0ecd52b9b41d3e23ecd9125 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:29:53 +0200 Subject: [PATCH 15/45] Update --- config/initializers/content_security_policy.rb | 13 ++++++------- config/initializers/filter_parameter_logging.rb | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 96bd2228..35ab3fd6 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -2,9 +2,9 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do # config.content_security_policy do |policy| @@ -18,11 +18,10 @@ # # policy.report_uri "/csp-violation-report-endpoint" # end # -# # Generate session nonces for permitted importmap and inline scripts +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # -# # Report CSP violations to a specified URI. See: -# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index ca55f952..a119afa1 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -2,9 +2,9 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] From 3170f018123ec3326a5219c6850f7e6d1b3e7ade Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:30:13 +0200 Subject: [PATCH 16/45] Update --- config/locales/en.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ca56fc7..6c349ae5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,6 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. +# Files in the config/locales directory are used for internationalization and +# are automatically loaded by Rails. If you want to use locales other than +# English, add the necessary files in this directory. # # To use the locales, use `I18n.t`: # @@ -16,18 +16,16 @@ # # This would use the information in config/locales/es.yml. # -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. # -# true, false, on, off, yes, no +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: # -# Instead, surround them with single quotes. -# -# en: -# "true": "foo" -# -# To learn more, please read the Rails Internationalization guide -# available at https://guides.rubyonrails.org/i18n.html. +# en: +# "yes": yup +# enabled: "ON" en: hello: "Hello world" From 32605415330ae1cfbee82fbaf5b6e88dc8acafff Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:32:30 +0200 Subject: [PATCH 17/45] Update --- config/application.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 57b3ab26..0ca90bce 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,12 @@ module EvemonkPgExtras class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: ["assets", "tasks"]) # Configuration for the application, engines, and railties goes here. # From 7bac2854d3a586e5c3d3cbc78f8488090d3603d4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:34:21 +0200 Subject: [PATCH 18/45] Update --- config/environments/development.rb | 6 ++-- config/environments/production.rb | 52 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 25457a6a..4c2957e8 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -8,7 +8,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -56,6 +56,6 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 1154b09e..60fc16f9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,7 +6,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -18,13 +18,12 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it). + config.public_file_server.enabled = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -33,23 +32,29 @@ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [:request_id] + # Info include generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "evemonk_pg_extras_production" - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true @@ -57,19 +62,14 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new # rubocop:disable Style/RedundantConstantBase - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end From 6a76c6b6f4185bc1789eeb417760fe6e8f1adfa0 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:35:23 +0200 Subject: [PATCH 19/45] Update --- config/environments/test.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 09955139..be845173 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,12 +10,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. @@ -30,7 +31,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -49,4 +50,7 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end From e9d19213ea2eaf38e789af044d46e087caa17ad4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:37:33 +0200 Subject: [PATCH 20/45] Update --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index ed6cf236..320355a0 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ Service container for running [rails-pg-extras](https://github.com/pawurb/rails- |------------------------------------------------|--------------------------------------------------------------------------------|---------------|----------------------| | `RAILS_ENV` | Rails environment | `development` | `production` | | `SECRET_KEY_BASE` | Rails secret | not set | not set | -| `RAILS_LOG_TO_STDOUT` | Log everything to stdout | not set | `true` | -| `RAILS_SERVE_STATIC_FILES` | Serve static assets from /public | not set | `true` | | `RAILS_MAX_THREADS` | Rails max threads | `2` | as default | | `RAILS_MIN_THREADS` | Rails min threads | `2` | as default | | `DATABASE_URL` | Database configuration. Example: `postgres://user:password@localhost/database` | not set | not set | From c70ebc8ba530fc7934a5d1b9256294614c2963e0 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:38:28 +0200 Subject: [PATCH 21/45] Update --- config/database.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config/database.yml b/config/database.yml index e9788b1f..e6427597 100644 --- a/config/database.yml +++ b/config/database.yml @@ -4,8 +4,6 @@ # gem install pg # On macOS with Homebrew: # gem install pg -- --with-pg-config=/usr/local/bin/pg_config -# On macOS with MacPorts: -# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg # Choose the win32 build. @@ -25,13 +23,13 @@ development: <<: *default database: evemonk_development - # The specified database role being used to connect to postgres. - # To create additional roles in postgres see `$ createuser --help`. - # When left blank, postgres will use the default role. This is + # The specified database role being used to connect to PostgreSQL. + # To create additional roles in PostgreSQL see `$ createuser --help`. + # When left blank, PostgreSQL will use the default role. This is # the same name as the operating system user running Rails. #username: evemonk_pg_extras - # The password associated with the postgres role (username). + # The password associated with the PostgreSQL role (username). #password: # Connect on a TCP socket. Omitted by default since the client uses a From 9bde64f46faf2709ee0bc272377a45df50a8890c Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:39:19 +0200 Subject: [PATCH 22/45] rails g rspec:install --- .rspec | 1 + spec/rails_helper.rb | 63 +++++++++++++++++++++++++++++ spec/spec_helper.rb | 94 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 .rspec create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..c99d2e73 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..c718176c --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,63 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://rspec.info/features/6-0/rspec-rails + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..327b58ea --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,94 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 2df01767cc01f4479e0b63fc8afb1c7c62f0d46a Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:41:02 +0200 Subject: [PATCH 23/45] Configure rspec --- .rspec | 1 + spec/spec_helper.rb | 28 ++-------------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/.rspec b/.rspec index c99d2e73..5be63fcb 100644 --- a/.rspec +++ b/.rspec @@ -1 +1,2 @@ --require spec_helper +--format documentation diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 327b58ea..e221eac7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -44,36 +46,11 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. config.example_status_persistence_file_path = "spec/examples.txt" - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. @@ -90,5 +67,4 @@ # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed -=end end From 7d4ea42e34e3aa8938ce8162dd6e378577980481 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:41:46 +0200 Subject: [PATCH 24/45] Configure rspec --- spec/rails_helper.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c718176c..92f8dbb2 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' -require 'spec_helper' -ENV['RAILS_ENV'] ||= 'test' -require_relative '../config/environment' +require "spec_helper" +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? -require 'rspec/rails' +require "rspec/rails" # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in @@ -30,9 +32,6 @@ abort e.to_s.strip end RSpec.configure do |config| - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. From 538900754ea28ffbc9fe50c63d8a32cb6607b49f Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:42:54 +0200 Subject: [PATCH 25/45] Add simplecov gem --- Gemfile | 4 ++++ Gemfile.lock | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Gemfile b/Gemfile index a53df5b2..bce99518 100644 --- a/Gemfile +++ b/Gemfile @@ -35,3 +35,7 @@ group :development do gem "brakeman", require: false gem "fasterer", require: false end + +group :test do + gem "simplecov", require: false +end diff --git a/Gemfile.lock b/Gemfile.lock index 06343fd3..01bac796 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,7 @@ GEM crass (1.0.6) date (3.3.3) diff-lcs (1.5.0) + docile (1.4.0) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -267,6 +268,12 @@ GEM sexp_processor (~> 4.16) rubyzip (2.3.2) sexp_processor (4.17.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) sshkit (1.21.5) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) @@ -324,6 +331,7 @@ DEPENDENCIES rubocop-disable_syntax rubocop-performance rubocop-rails + simplecov sshkit standard (= 1.31.2) tzinfo-data From c26d68099b57218e50edafca1c2d188acc2c71b4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:43:12 +0200 Subject: [PATCH 26/45] Configure simplecov gem --- spec/spec_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e221eac7..7c00adb7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,13 @@ # frozen_string_literal: true +require "simplecov" + +SimpleCov.start "rails" do + enable_coverage :branch + primary_coverage :branch + enable_coverage_for_eval +end + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From 7bf19c213db6044a752b1a33a5cdf3bd078399c6 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:43:58 +0200 Subject: [PATCH 27/45] Test --- spec/helpers/application_helper_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spec/helpers/application_helper_spec.rb diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 00000000..008c7318 --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe ApplicationHelper do +end From 32a32fb7f1c9379f9d91601ffb50d40a2994f0cc Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:46:41 +0200 Subject: [PATCH 28/45] Tests --- spec/models/application_record_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 spec/models/application_record_spec.rb diff --git a/spec/models/application_record_spec.rb b/spec/models/application_record_spec.rb new file mode 100644 index 00000000..af743145 --- /dev/null +++ b/spec/models/application_record_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe ApplicationRecord do + it { expect(described_class.abstract_class).to eq(true) } + + it { expect(ActiveRecord.application_record_class).to eq(described_class) } +end From 0815255ad7bc2b5eddd057b97bf67b2a69d21eb9 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:48:37 +0200 Subject: [PATCH 29/45] Test --- spec/controllers/application_controller_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spec/controllers/application_controller_spec.rb diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb new file mode 100644 index 00000000..6563c52c --- /dev/null +++ b/spec/controllers/application_controller_spec.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe ApplicationController do +end From 0a34f10f556b110d589c7e4e30c7077f1f45d8c6 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 21:51:57 +0200 Subject: [PATCH 30/45] Routes --- config/routes.rb | 4 ++++ spec/routing/up_routing_spec.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/routing/up_routing_spec.rb diff --git a/config/routes.rb b/config/routes.rb index 27ce1be4..8e17633f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true Rails.application.routes.draw do + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get "up" => "rails/health#show", :as => :rails_health_check + mount RailsPgExtras::Web::Engine, at: "/" end diff --git a/spec/routing/up_routing_spec.rb b/spec/routing/up_routing_spec.rb new file mode 100644 index 00000000..1265acb6 --- /dev/null +++ b/spec/routing/up_routing_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe Rails::HealthController do + describe "routing" do + it "should route GET /up to rails/health#show" do + expect(get: "/up").to route_to( + controller: "rails/health", + action: "show" + ) + end + end +end From d73c42449bc2bc23d3260a16ffbb5590eecc4d66 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 22:13:07 +0200 Subject: [PATCH 31/45] Update --- config/puma.rb | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index d40a8d35..d46b7b69 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,45 +1,37 @@ # frozen_string_literal: true +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. + # 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. -# max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 2) min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count) threads min_threads_count, max_threads_count +# Specifies that the worker count should equal the number of processors in production. +# if ENV["RAILS_ENV"] == "production" +# require "concurrent-ruby" +# worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) +# workers worker_count if worker_count > 1 +# end + # Specifies the `worker_timeout` threshold that Puma will use to wait before # terminating a worker in development environments. -# worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # 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 `pidfile` that Puma will use. # pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid") -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server 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. -# -# preload_app! - # Allow puma to be restarted by `bin/rails restart` command. # plugin :tmp_restart From b3b8e1f16ee51b905569579ea26eb4885b3203ab Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 22:13:36 +0200 Subject: [PATCH 32/45] Update --- Dockerfile | 134 ++++++++++++++++--------------------------------- Dockerfile.old | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 92 deletions(-) create mode 100644 Dockerfile.old diff --git a/Dockerfile b/Dockerfile index be3d27fd..0cf17451 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,109 +1,59 @@ -FROM ruby:3.2.2-slim AS builder +# syntax = docker/dockerfile:1 -# skipcq: DOK-DL3008 -RUN set -eux; \ - apt-get update -y ; \ - apt-get dist-upgrade -y ; \ - apt-get install git patch xz-utils gcc make libpq-dev libjemalloc2 shared-mime-info --no-install-recommends -y ; \ - apt-get autoremove -y ; \ - apt-get clean -y ; \ - rm -rf /var/lib/apt/lists/* +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile +ARG RUBY_VERSION=3.2.2 +FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base -RUN mkdir -p /app +# Rails app lives here +WORKDIR /rails -WORKDIR /app +# Set production environment +ENV RAILS_ENV="production" \ + BUNDLE_DEPLOYMENT="1" \ + BUNDLE_PATH="/usr/local/bundle" \ + BUNDLE_WITHOUT="development" -COPY .ruby-version .ruby-version -COPY Gemfile Gemfile +# Throw-away build stage to reduce size of final image +FROM base as build -COPY Gemfile.lock Gemfile.lock +# Install packages needed to build gems +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config -ENV RAILS_ENV production - -ENV RAILS_LOG_TO_STDOUT true - -RUN gem update --system "3.4.20" - -# skipcq: DOK-DL3028 -RUN gem install bundler --version "2.4.20" --force - -RUN gem --version - -RUN bundle --version - -# throw errors if Gemfile has been modified since Gemfile.lock -RUN bundle config set --global frozen 1 - -# two jobs -RUN bundle config set --global jobs 2 - -# install only production gems without development and test -RUN bundle config set --global without development test - -# retry 5 times before fail -RUN bundle config set --global retry 5 - -RUN bundle install - -RUN rm -rf /usr/local/bundle/cache/*.gem - -RUN find /usr/local/bundle/gems/ -name "*.c" -delete - -RUN find /usr/local/bundle/gems/ -name "*.o" -delete +# Install application gems +COPY Gemfile Gemfile.lock ./ +RUN bundle install && \ + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ + bundle exec bootsnap precompile --gemfile +# Copy application code COPY . . -RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ - -FROM ruby:3.2.2-slim - -LABEL maintainer="Igor Zubkov " - -# skipcq: DOK-DL3008 -RUN set -eux; \ - apt-get update -y ; \ - apt-get dist-upgrade -y ; \ - apt-get install libpq5 libjemalloc2 shared-mime-info --no-install-recommends -y ; \ - apt-get autoremove -y ; \ - apt-get clean -y ; \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -RUN groupadd --gid 1000 app - -RUN useradd --uid 1000 --no-log-init --create-home --gid app app - -USER app - -COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ -COPY --from=builder /usr/local/bin/ /usr/local/bin/ -COPY --from=builder --chown=app:app /app /app - -# install only production gems without development and test -RUN bundle config set --global without development test - -ARG COMMIT="" - -ENV COMMIT_SHA=${COMMIT} - -ENV RAILS_ENV production - -ENV RAILS_LOG_TO_STDOUT true - -ENV RAILS_SERVE_STATIC_FILES true +# Precompile bootsnap code for faster boot times +RUN bundle exec bootsnap precompile app/ lib/ -ENV BOOTSNAP_LOG true -ENV BOOTSNAP_READONLY true +# Final stage for app image +FROM base -ENV RUBY_YJIT_ENABLE 1 +# Install packages needed for deployment +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y curl postgresql-client && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives -ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 +# Copy built artifacts: gems, application +COPY --from=build /usr/local/bundle /usr/local/bundle +COPY --from=build /rails /rails -SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# Run and own only the runtime files as a non-root user for security +RUN useradd rails --create-home --shell /bin/bash && \ + chown -R rails:rails db log tmp +USER rails:rails -EXPOSE 3000/tcp +# Entrypoint prepares the database. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] -ENTRYPOINT ["bundle", "exec", "puma", "-C", "config/puma.rb"] +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +CMD ["./bin/rails", "server"] diff --git a/Dockerfile.old b/Dockerfile.old new file mode 100644 index 00000000..be3d27fd --- /dev/null +++ b/Dockerfile.old @@ -0,0 +1,109 @@ +FROM ruby:3.2.2-slim AS builder + +# skipcq: DOK-DL3008 +RUN set -eux; \ + apt-get update -y ; \ + apt-get dist-upgrade -y ; \ + apt-get install git patch xz-utils gcc make libpq-dev libjemalloc2 shared-mime-info --no-install-recommends -y ; \ + apt-get autoremove -y ; \ + apt-get clean -y ; \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /app + +WORKDIR /app + +COPY .ruby-version .ruby-version + +COPY Gemfile Gemfile + +COPY Gemfile.lock Gemfile.lock + +ENV RAILS_ENV production + +ENV RAILS_LOG_TO_STDOUT true + +RUN gem update --system "3.4.20" + +# skipcq: DOK-DL3028 +RUN gem install bundler --version "2.4.20" --force + +RUN gem --version + +RUN bundle --version + +# throw errors if Gemfile has been modified since Gemfile.lock +RUN bundle config set --global frozen 1 + +# two jobs +RUN bundle config set --global jobs 2 + +# install only production gems without development and test +RUN bundle config set --global without development test + +# retry 5 times before fail +RUN bundle config set --global retry 5 + +RUN bundle install + +RUN rm -rf /usr/local/bundle/cache/*.gem + +RUN find /usr/local/bundle/gems/ -name "*.c" -delete + +RUN find /usr/local/bundle/gems/ -name "*.o" -delete + +COPY . . + +RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ + +FROM ruby:3.2.2-slim + +LABEL maintainer="Igor Zubkov " + +# skipcq: DOK-DL3008 +RUN set -eux; \ + apt-get update -y ; \ + apt-get dist-upgrade -y ; \ + apt-get install libpq5 libjemalloc2 shared-mime-info --no-install-recommends -y ; \ + apt-get autoremove -y ; \ + apt-get clean -y ; \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +RUN groupadd --gid 1000 app + +RUN useradd --uid 1000 --no-log-init --create-home --gid app app + +USER app + +COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ +COPY --from=builder /usr/local/bin/ /usr/local/bin/ +COPY --from=builder --chown=app:app /app /app + +# install only production gems without development and test +RUN bundle config set --global without development test + +ARG COMMIT="" + +ENV COMMIT_SHA=${COMMIT} + +ENV RAILS_ENV production + +ENV RAILS_LOG_TO_STDOUT true + +ENV RAILS_SERVE_STATIC_FILES true + +ENV BOOTSNAP_LOG true + +ENV BOOTSNAP_READONLY true + +ENV RUBY_YJIT_ENABLE 1 + +ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +EXPOSE 3000/tcp + +ENTRYPOINT ["bundle", "exec", "puma", "-C", "config/puma.rb"] From 998a1f8e42082f31b803ab6d25afa57b4990d419 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 22:14:11 +0200 Subject: [PATCH 33/45] Add bundler-audit gem --- Gemfile | 1 + Gemfile.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index bce99518..7a28e0b5 100644 --- a/Gemfile +++ b/Gemfile @@ -34,6 +34,7 @@ group :development do gem "standard", "1.31.2", require: false gem "brakeman", require: false gem "fasterer", require: false + gem "bundler-audit", require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 01bac796..474ac007 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,9 @@ GEM msgpack (~> 1.2) brakeman (6.0.1) builder (3.2.4) + bundler-audit (0.9.1) + bundler (>= 1.2.0, < 3) + thor (~> 1.0) coderay (1.1.3) colorize (0.8.1) concurrent-ruby (1.2.2) @@ -318,6 +321,7 @@ PLATFORMS DEPENDENCIES bootsnap brakeman + bundler-audit dotenv-rails fasterer license_finder From f09b3b6d195aa2f24d2f792383c75cb876066d07 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Sun, 15 Oct 2023 22:14:31 +0200 Subject: [PATCH 34/45] Binstubs --- bin/bundle-audit | 27 +++++++++++++++++++++++++++ bin/bundler-audit | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 bin/bundle-audit create mode 100755 bin/bundler-audit diff --git a/bin/bundle-audit b/bin/bundle-audit new file mode 100755 index 00000000..a0e7ba0e --- /dev/null +++ b/bin/bundle-audit @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle-audit' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("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("bundler-audit", "bundle-audit") diff --git a/bin/bundler-audit b/bin/bundler-audit new file mode 100755 index 00000000..334a7378 --- /dev/null +++ b/bin/bundler-audit @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundler-audit' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("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("bundler-audit", "bundler-audit") From 14b1081d99f3466625625884cf85ae9a2476b432 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:10:29 +0200 Subject: [PATCH 35/45] Use bin/bundle-audit --- .github/workflows/bundler-audit.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bundler-audit.yml b/.github/workflows/bundler-audit.yml index eb00c19a..27e73243 100644 --- a/.github/workflows/bundler-audit.yml +++ b/.github/workflows/bundler-audit.yml @@ -16,5 +16,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: "Bundler Audit" - uses: andrewmcodes/bundler-audit-action@main + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - run: bin/bundle-audit update + - run: bin/bundle-audit check From 7e67d2f6b3d897759744ecb63777b971330c520b Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:12:03 +0200 Subject: [PATCH 36/45] Update --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 49c864ae..bda37176 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ !/tmp/pids/ !/tmp/pids/.keep - /public/assets .idea/**/* .env +spec/examples.txt From 98fe429851b2b14ad4cafb272743437bb901d2b4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:13:53 +0200 Subject: [PATCH 37/45] Cleanup --- config/environments/production.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 60fc16f9..19254645 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -40,8 +40,8 @@ config.force_ssl = true # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. From 17291979615f42a6381ab0c23ef68bf87f6c03b5 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:16:43 +0200 Subject: [PATCH 38/45] Update --- Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0cf17451..751d45d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ ARG RUBY_VERSION=3.2.2 FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +LABEL maintainer="Igor Zubkov " + # Rails app lives here WORKDIR /rails @@ -11,8 +13,16 @@ WORKDIR /rails ENV RAILS_ENV="production" \ BUNDLE_DEPLOYMENT="1" \ BUNDLE_PATH="/usr/local/bundle" \ - BUNDLE_WITHOUT="development" - + BUNDLE_WITHOUT="development:test" \ + BOOTSNAP_LOG="true" \ + BOOTSNAP_READONLY="true" \ + RUBY_YJIT_ENABLE="1" + +RUN set -eux; \ + gem update --system "3.4.20" ; \ + gem install bundler --version "2.4.20" --force ; \ + gem --version ; \ + bundle --version # Throw-away build stage to reduce size of final image FROM base as build From 9b69df3763400d2c2a9cf940bf9e0431cdbed550 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:17:45 +0200 Subject: [PATCH 39/45] Update --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 751d45d9..c4fb3fd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,8 +28,11 @@ RUN set -eux; \ FROM base as build # Install packages needed to build gems -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config +# skipcq: DOK-DL3008 +RUN set -eux; \ + apt-get update -qq ; \ + apt-get dist-upgrade -qq ; \ + apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config shared-mime-info # Install application gems COPY Gemfile Gemfile.lock ./ From 91919c6cd94c5a281471971af7c1f9d736af5f31 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 11:19:29 +0200 Subject: [PATCH 40/45] Update --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4fb3fd6..0ced5ce0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,9 +35,10 @@ RUN set -eux; \ apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config shared-mime-info # Install application gems -COPY Gemfile Gemfile.lock ./ -RUN bundle install && \ - rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ +COPY .ruby-version Gemfile Gemfile.lock ./ +RUN set -eux; \ + bundle install ; \ + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git ; \ bundle exec bootsnap precompile --gemfile # Copy application code From f3969a4efa2f34eb1dd3aaf43e02ca873069c33a Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 12:45:25 +0200 Subject: [PATCH 41/45] Update --- Dockerfile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ced5ce0..fd08e6cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,8 +52,12 @@ RUN bundle exec bootsnap precompile app/ lib/ FROM base # Install packages needed for deployment -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl postgresql-client && \ +RUN set -eux; \ + apt-get update -qq ; \ + apt-get dist-upgrade -qq ; \ + apt-get install --no-install-recommends -y curl postgresql-client libjemalloc2 shared-mime-info ; \ + apt-get autoremove -y ; \ + apt-get clean -y ; \ rm -rf /var/lib/apt/lists /var/cache/apt/archives # Copy built artifacts: gems, application @@ -61,13 +65,20 @@ COPY --from=build /usr/local/bundle /usr/local/bundle COPY --from=build /rails /rails # Run and own only the runtime files as a non-root user for security -RUN useradd rails --create-home --shell /bin/bash && \ +RUN set -eux; \ + useradd rails --create-home --shell /bin/bash ; \ chown -R rails:rails db log tmp + USER rails:rails +ENV LD_PRELOAD="libjemalloc.so.2" + # Entrypoint prepares the database. ENTRYPOINT ["/rails/bin/docker-entrypoint"] +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + # Start the server by default, this can be overwritten at runtime -EXPOSE 3000 +EXPOSE 3000/tcp + CMD ["./bin/rails", "server"] From d0a1b567d95685b75e7a6203cd2ec96c414d11a4 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 12:45:55 +0200 Subject: [PATCH 42/45] Cleanup --- Dockerfile.old | 109 ------------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 Dockerfile.old diff --git a/Dockerfile.old b/Dockerfile.old deleted file mode 100644 index be3d27fd..00000000 --- a/Dockerfile.old +++ /dev/null @@ -1,109 +0,0 @@ -FROM ruby:3.2.2-slim AS builder - -# skipcq: DOK-DL3008 -RUN set -eux; \ - apt-get update -y ; \ - apt-get dist-upgrade -y ; \ - apt-get install git patch xz-utils gcc make libpq-dev libjemalloc2 shared-mime-info --no-install-recommends -y ; \ - apt-get autoremove -y ; \ - apt-get clean -y ; \ - rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /app - -WORKDIR /app - -COPY .ruby-version .ruby-version - -COPY Gemfile Gemfile - -COPY Gemfile.lock Gemfile.lock - -ENV RAILS_ENV production - -ENV RAILS_LOG_TO_STDOUT true - -RUN gem update --system "3.4.20" - -# skipcq: DOK-DL3028 -RUN gem install bundler --version "2.4.20" --force - -RUN gem --version - -RUN bundle --version - -# throw errors if Gemfile has been modified since Gemfile.lock -RUN bundle config set --global frozen 1 - -# two jobs -RUN bundle config set --global jobs 2 - -# install only production gems without development and test -RUN bundle config set --global without development test - -# retry 5 times before fail -RUN bundle config set --global retry 5 - -RUN bundle install - -RUN rm -rf /usr/local/bundle/cache/*.gem - -RUN find /usr/local/bundle/gems/ -name "*.c" -delete - -RUN find /usr/local/bundle/gems/ -name "*.o" -delete - -COPY . . - -RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ - -FROM ruby:3.2.2-slim - -LABEL maintainer="Igor Zubkov " - -# skipcq: DOK-DL3008 -RUN set -eux; \ - apt-get update -y ; \ - apt-get dist-upgrade -y ; \ - apt-get install libpq5 libjemalloc2 shared-mime-info --no-install-recommends -y ; \ - apt-get autoremove -y ; \ - apt-get clean -y ; \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -RUN groupadd --gid 1000 app - -RUN useradd --uid 1000 --no-log-init --create-home --gid app app - -USER app - -COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ -COPY --from=builder /usr/local/bin/ /usr/local/bin/ -COPY --from=builder --chown=app:app /app /app - -# install only production gems without development and test -RUN bundle config set --global without development test - -ARG COMMIT="" - -ENV COMMIT_SHA=${COMMIT} - -ENV RAILS_ENV production - -ENV RAILS_LOG_TO_STDOUT true - -ENV RAILS_SERVE_STATIC_FILES true - -ENV BOOTSNAP_LOG true - -ENV BOOTSNAP_READONLY true - -ENV RUBY_YJIT_ENABLE 1 - -ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -EXPOSE 3000/tcp - -ENTRYPOINT ["bundle", "exec", "puma", "-C", "config/puma.rb"] From a7c8c393654f6606a75e8a6d6a58876cf14c2751 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 12:47:50 +0200 Subject: [PATCH 43/45] Update --- doc/dependency_decisions.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index 9017eb26..988c14e1 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -41,3 +41,9 @@ :why: :versions: [] :when: 2021-08-23 22:38:36.894888000 Z +- - :permit + - ruby + - :who: "@biow0lf" + :why: + :versions: [] + :when: 2023-10-16 10:47:22.959692000 Z From 9aad12caf8f4702e164442cd30c400cb15a3d625 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 12:49:56 +0200 Subject: [PATCH 44/45] Update --- .dockerignore | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 676235d9..59aa03cb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,33 @@ -.git/* +# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. + +# Ignore git directory. +/.git/ + +# Ignore bundler config. +/.bundle + +# Ignore all environment files (except templates). +/.env* +!/.env*.erb + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/.keep + +# Ignore assets. +/node_modules/ +/app/assets/builds/* +!/app/assets/builds/.keep +/public/assets + .github/* .idea/* -.env -.env.example .deepsource.toml .generators .fasterer.yml From be48271198caca499e3c62f52183b75e07c56dbc Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Mon, 16 Oct 2023 12:50:32 +0200 Subject: [PATCH 45/45] Update --- .dockerignore | 1 + .gitignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index 59aa03cb..161a61b5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -37,3 +37,4 @@ .mdlrc .rubocop.yml .standard.yml +coverage/* diff --git a/.gitignore b/.gitignore index bda37176..bd632e54 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ .idea/**/* .env spec/examples.txt +coverage/*