From bfc5c6bf9dd62175c91a73db5803498b205d422a Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 17:27:02 +0800 Subject: [PATCH 01/24] Test webrick gem --- Gemfile | 2 ++ Gemfile.lock | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 888236a89..ebb39b73b 100644 --- a/Gemfile +++ b/Gemfile @@ -136,6 +136,8 @@ gem 'net-imap' gem 'matrix' +gem 'webrick' + # ------------------------------------------------------------------ Deployment # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 91046f158..cf257070e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -497,6 +497,7 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) + webrick (1.7.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -603,6 +604,7 @@ DEPENDENCIES warden (~> 1.2.3) web-console (>= 4.1.0) webdrivers + webrick whenever RUBY VERSION From 4924fbecaa9b8af56015a455af12ac4669dd044b Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 17:50:37 +0800 Subject: [PATCH 02/24] Try using puma --- Gemfile | 5 ++--- Gemfile.lock | 2 -- app.json | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index ebb39b73b..803835a96 100644 --- a/Gemfile +++ b/Gemfile @@ -136,7 +136,8 @@ gem 'net-imap' gem 'matrix' -gem 'webrick' + +gem 'puma', '~> 5.0' # ------------------------------------------------------------------ Deployment # Use Capistrano for deployment @@ -185,8 +186,6 @@ group :development, :test do gem 'byebug', platform: :mri gem 'rspec-rails', '~> 4.0.2' - - gem 'puma', '~> 5.0' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index cf257070e..91046f158 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -497,7 +497,6 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - webrick (1.7.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -604,7 +603,6 @@ DEPENDENCIES warden (~> 1.2.3) web-console (>= 4.1.0) webdrivers - webrick whenever RUBY VERSION diff --git a/app.json b/app.json index ed08ea592..3455a4d17 100644 --- a/app.json +++ b/app.json @@ -20,7 +20,7 @@ "keywords": ["infosec", "pentest", "osint"], "logo": "https://github.com/dradis/dradis-ce/raw/deploy-to-heroku/app/assets/images/logo_small.png", "name": "Dradis Framework - Community Edition", - "repository": "https://github.com/dradis/dradis-ce/tree/deploy-to-heroku", + "repository": "https://github.com/dradis/dradis-ce/tree/develop", "scripts": { "postdeploy": "bin/heroku" }, From b526c084286c966b88c9dc7604bc025928591ab5 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 18:17:44 +0800 Subject: [PATCH 03/24] Test puma --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 803835a96..0ac03d635 100644 --- a/Gemfile +++ b/Gemfile @@ -137,8 +137,6 @@ gem 'net-imap' gem 'matrix' -gem 'puma', '~> 5.0' - # ------------------------------------------------------------------ Deployment # Use Capistrano for deployment # gem 'capistrano-rails', group: :development @@ -186,6 +184,8 @@ group :development, :test do gem 'byebug', platform: :mri gem 'rspec-rails', '~> 4.0.2' + + gem 'puma', '~> 5.0' end group :test do From 76e0083ed31056cfb8170414e14859c56be2695b Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 18:40:19 +0800 Subject: [PATCH 04/24] Revert "Test puma" This reverts commit b526c084286c966b88c9dc7604bc025928591ab5. --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 0ac03d635..803835a96 100644 --- a/Gemfile +++ b/Gemfile @@ -137,6 +137,8 @@ gem 'net-imap' gem 'matrix' +gem 'puma', '~> 5.0' + # ------------------------------------------------------------------ Deployment # Use Capistrano for deployment # gem 'capistrano-rails', group: :development @@ -184,8 +186,6 @@ group :development, :test do gem 'byebug', platform: :mri gem 'rspec-rails', '~> 4.0.2' - - gem 'puma', '~> 5.0' end group :test do From 1dc51660bb749673737e4e05ec67e97c06f6ec36 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 19:05:59 +0800 Subject: [PATCH 05/24] Test hardcoded branch --- .do/deploy.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index aca304932..cc30cf531 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -10,7 +10,7 @@ spec: value: enabled scope: RUN_TIME git: - branch: develop + branch: fix-heroku-1-click repo_clone_url: https://github.com/dradis/dradis-ce.git name: web run_command: ./bin/setup From aa420b6bdbad11a083d2cb0ad887fb254cb77ef5 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 28 Jul 2022 17:27:02 +0800 Subject: [PATCH 06/24] Test webrick gem --- .do/deploy.template.yaml | 3 +-- .gitignore | 1 - Procfile | 1 + app.json | 2 +- config/database.yml | 36 ++++++++++++++++++++++++++++++++++++ config/unicorn.rb | 22 ++++++++++++++++++++++ 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 Procfile create mode 100644 config/database.yml create mode 100644 config/unicorn.rb diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index aca304932..9d1497b21 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -10,7 +10,6 @@ spec: value: enabled scope: RUN_TIME git: - branch: develop + branch: fix-heroku-1-click repo_clone_url: https://github.com/dradis/dradis-ce.git name: web - run_command: ./bin/setup diff --git a/.gitignore b/.gitignore index b618c7c5f..e3229c284 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ # Rails stuff /db/*.sqlite3 /db/*.sqlite3-* -/config/database.yml /config/secrets.yml /config/smtp.yml /log/* diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..9c8237414 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb diff --git a/app.json b/app.json index ed08ea592..3455a4d17 100644 --- a/app.json +++ b/app.json @@ -20,7 +20,7 @@ "keywords": ["infosec", "pentest", "osint"], "logo": "https://github.com/dradis/dradis-ce/raw/deploy-to-heroku/app/assets/images/logo_small.png", "name": "Dradis Framework - Community Edition", - "repository": "https://github.com/dradis/dradis-ce/tree/deploy-to-heroku", + "repository": "https://github.com/dradis/dradis-ce/tree/develop", "scripts": { "postdeploy": "bin/heroku" }, diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 000000000..196f708f8 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,36 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# MySQL version - make sure the mysql2 gem is included in your Gemfile +# If you uncomment this development: block, comment the previous one. +# development: +# adapter: mysql2 +# encoding: utf8 +# collation: utf8_bin +# database: dradis_dev +# username: root +# socket: /tmp/mysql.sock + + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 000000000..f6e59b8f2 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,22 @@ +worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) +timeout 15 +preload_app true + +before_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn master intercepting TERM and sending myself QUIT instead' + Process.kill 'QUIT', Process.pid + end + + defined?(ActiveRecord::Base) and + ActiveRecord::Base.connection.disconnect! +end + +after_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' + end + + defined?(ActiveRecord::Base) and + ActiveRecord::Base.establish_connection +end From 6c9dbd53693643bcdadfb9a68048919a28300264 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 28 Nov 2022 17:47:47 +0800 Subject: [PATCH 07/24] Revert changes --- .do/deploy.template.yaml | 3 ++- .gitignore | 1 + config/database.yml | 36 ------------------------------------ config/unicorn.rb | 22 ---------------------- 4 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 config/database.yml delete mode 100644 config/unicorn.rb diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 9d1497b21..aca304932 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -10,6 +10,7 @@ spec: value: enabled scope: RUN_TIME git: - branch: fix-heroku-1-click + branch: develop repo_clone_url: https://github.com/dradis/dradis-ce.git name: web + run_command: ./bin/setup diff --git a/.gitignore b/.gitignore index e3229c284..b618c7c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Rails stuff /db/*.sqlite3 /db/*.sqlite3-* +/config/database.yml /config/secrets.yml /config/smtp.yml /log/* diff --git a/config/database.yml b/config/database.yml deleted file mode 100644 index 196f708f8..000000000 --- a/config/database.yml +++ /dev/null @@ -1,36 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -# -default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - -development: - <<: *default - database: db/development.sqlite3 - -# MySQL version - make sure the mysql2 gem is included in your Gemfile -# If you uncomment this development: block, comment the previous one. -# development: -# adapter: mysql2 -# encoding: utf8 -# collation: utf8_bin -# database: dradis_dev -# username: root -# socket: /tmp/mysql.sock - - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: db/test.sqlite3 - -production: - <<: *default - database: db/production.sqlite3 diff --git a/config/unicorn.rb b/config/unicorn.rb deleted file mode 100644 index f6e59b8f2..000000000 --- a/config/unicorn.rb +++ /dev/null @@ -1,22 +0,0 @@ -worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) -timeout 15 -preload_app true - -before_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn master intercepting TERM and sending myself QUIT instead' - Process.kill 'QUIT', Process.pid - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! -end - -after_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' - end - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection -end From ce8b8814e2e173c8b0428e89b22785c11c70a54f Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 28 Nov 2022 17:51:21 +0800 Subject: [PATCH 08/24] Remove config usage --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 9c8237414..5784a1747 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb +web: bundle exec unicorn -p $PORT From 61cb6a02e10c6b04ed84d4de964f0be1c8105772 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Fri, 6 Jan 2023 16:07:45 +0800 Subject: [PATCH 09/24] Test hardcoded port --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 5784a1747..d307e657a 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec unicorn -p $PORT +web: bundle exec unicorn -p 5432 From 1b4da2c3282d32b9649449bcf1d75e12a0845b92 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Fri, 6 Jan 2023 16:12:21 +0800 Subject: [PATCH 10/24] Try using postgresql addon --- app.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.json b/app.json index 3455a4d17..461fff74f 100644 --- a/app.json +++ b/app.json @@ -8,6 +8,9 @@ }, { "url": "heroku/ruby" + }, + { + "url": "heroku/postgresql" } ], "description": "The original open-source reporting and collaboration tool trusted by InfoSec professionals around the world.", From 27a8db1c491e12bbceb8cbc7a772fcb14826b16b Mon Sep 17 00:00:00 2001 From: Daniel Martin <53006+etdsoft@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:14:58 +0100 Subject: [PATCH 11/24] Add Heroku DB bypass --- config/initializers/_heroku.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 config/initializers/_heroku.rb diff --git a/config/initializers/_heroku.rb b/config/initializers/_heroku.rb new file mode 100644 index 000000000..adbca0685 --- /dev/null +++ b/config/initializers/_heroku.rb @@ -0,0 +1,21 @@ +# In Heroku, assets:precompile is run before the DB is provisioned causing a +# ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", +# port 5432 failed: Connection refused +# +# We run into this problem because dradis-plugins uses a :enabled/disabled DB +# setting for each integration to decide whether to load them or not. +# +# See: +# https://devcenter.heroku.com/articles/rails-asset-pipeline +# + +Rails.application.reloader.to_prepare do + # only Heroku sets this + if ENV['DATABASE_URL'] + # DB isn't ready yet + if !(ActiveRecord::Base.connection rescue false) + # Empty the list of integrations. + Dradis::Plugins::class_variable_set('@@enabled_list', []) + end + end +end From 6167430ab7f786d7286334ac7de81497ef094b96 Mon Sep 17 00:00:00 2001 From: Daniel Martin <53006+etdsoft@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:20:29 +0100 Subject: [PATCH 12/24] Bump Ruby version to 3.1.3 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index ef538c281..ff365e06b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.1.3 From e25dc5cc9cfc868fcce86215b160901b19b8e7d4 Mon Sep 17 00:00:00 2001 From: Daniel Martin <53006+etdsoft@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:27:31 +0100 Subject: [PATCH 13/24] Temporarily add HEROKU_DEBUG_RAILS_RUNNER --- app.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.json b/app.json index 461fff74f..a259bad8b 100644 --- a/app.json +++ b/app.json @@ -18,6 +18,9 @@ "RAILS_SERVE_STATIC_FILES": { "description": "Ask Rails to serve static assets", "value": "1" + }, + "HEROKU_DEBUG_RAILS_RUNNER": { + "value": "1" } }, "keywords": ["infosec", "pentest", "osint"], From 5fce6c3fc7bb68398e67c8a5870e7fcd26dbbe13 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 27 Apr 2023 16:33:57 +0800 Subject: [PATCH 14/24] Test ruby version revert --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index ff365e06b..ef538c281 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.3 +3.1.2 From 022aad2d93c69fad0c1c52b532565862d41da9b1 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 27 Apr 2023 16:52:12 +0800 Subject: [PATCH 15/24] Add HEROKU_DEBUG_RAILS_RUNNER --- .do/deploy.template.yaml | 2 ++ Gemfile | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index cc30cf531..2b4f6f421 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -9,6 +9,8 @@ spec: - key: RAILS_SERVE_STATIC_FILES value: enabled scope: RUN_TIME + - key: HEROKU_DEBUG_RAILS_RUNNER + value: '1' git: branch: fix-heroku-1-click repo_clone_url: https://github.com/dradis/dradis-ce.git diff --git a/Gemfile b/Gemfile index 5e9a5e2e1..952fd3f47 100644 --- a/Gemfile +++ b/Gemfile @@ -136,7 +136,6 @@ gem 'net-imap' gem 'matrix' - gem 'puma', '~> 5.0' # ------------------------------------------------------------------ Deployment From 57ab759cfdd8a50a4b42daea02823fe31f06870c Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Fri, 28 Apr 2023 19:20:36 +0800 Subject: [PATCH 16/24] Temporarily remove heroku button and add changelog entry --- CHANGELOG | 3 +-- README.md | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 35430edfe..caaa51411 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,8 +4,7 @@ - Upgraded gems: - [gem] - Bugs fixes: - - [entity]: - - [future tense verb] [bug fix] + - Digital Ocean: Fix one click deploy button - Bug tracker items: - [item] - New integrations: diff --git a/README.md b/README.md index 8396613a0..03a914f25 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Dradis is an open-source collaboration framework, tailored to InfoSec teams. - To try Dradis Community, you can deploy your own instance (you will need accounts in the cloud providers to get started). From 8d30f6d8de75c61b62bf7a9f51d01e58ab095981 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 11 May 2023 16:08:05 +0800 Subject: [PATCH 17/24] Remove unused heroku scripts --- app.json | 34 ---------------------------------- bin/heroku | 24 ------------------------ 2 files changed, 58 deletions(-) delete mode 100644 app.json delete mode 100755 bin/heroku diff --git a/app.json b/app.json deleted file mode 100644 index a259bad8b..000000000 --- a/app.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "buildpacks": [ - { - "url": "heroku-community/apt" - }, - { - "url": "heroku/nodejs" - }, - { - "url": "heroku/ruby" - }, - { - "url": "heroku/postgresql" - } - ], - "description": "The original open-source reporting and collaboration tool trusted by InfoSec professionals around the world.", - "env": { - "RAILS_SERVE_STATIC_FILES": { - "description": "Ask Rails to serve static assets", - "value": "1" - }, - "HEROKU_DEBUG_RAILS_RUNNER": { - "value": "1" - } - }, - "keywords": ["infosec", "pentest", "osint"], - "logo": "https://github.com/dradis/dradis-ce/raw/deploy-to-heroku/app/assets/images/logo_small.png", - "name": "Dradis Framework - Community Edition", - "repository": "https://github.com/dradis/dradis-ce/tree/develop", - "scripts": { - "postdeploy": "bin/heroku" - }, - "website": "http://drad.is" -} diff --git a/bin/heroku b/bin/heroku deleted file mode 100755 index 3fd15d928..000000000 --- a/bin/heroku +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby -require 'fileutils' - -# path to your application root. -APP_ROOT = File.expand_path('..', __dir__) - -def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") -end - -FileUtils.chdir APP_ROOT do - puts "\n== Copying sample files ==" - FileUtils.cp 'config/secrets.yml.template', 'config/secrets.yml' - FileUtils.cp 'config/smtp.yml.template', 'config/smtp.yml' - - puts "\n== Preparing templates folder ==" - FileUtils.mkdir 'templates' - - puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' - - puts "\n== Loading some sample content ==" - system! 'bundle exec thor dradis:setup:welcome' -end From 22610fca1103f1888e882ae2eb23ad86f2a4bcc5 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 11 May 2023 16:44:06 +0800 Subject: [PATCH 18/24] Rename app platform initializer --- config/initializers/{_heroku.rb => _preprovision_database.rb} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename config/initializers/{_heroku.rb => _preprovision_database.rb} (83%) diff --git a/config/initializers/_heroku.rb b/config/initializers/_preprovision_database.rb similarity index 83% rename from config/initializers/_heroku.rb rename to config/initializers/_preprovision_database.rb index adbca0685..a85cfaacf 100644 --- a/config/initializers/_heroku.rb +++ b/config/initializers/_preprovision_database.rb @@ -1,4 +1,4 @@ -# In Heroku, assets:precompile is run before the DB is provisioned causing a +# In App Platforms, assets:precompile is run before the DB is provisioned causing a # ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", # port 5432 failed: Connection refused # @@ -10,7 +10,7 @@ # Rails.application.reloader.to_prepare do - # only Heroku sets this + # This is set by the App Platforms if ENV['DATABASE_URL'] # DB isn't ready yet if !(ActiveRecord::Base.connection rescue false) From da15fa2247be02d7ab52699acffe31b6c461e24e Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 4 Apr 2024 17:41:44 +0800 Subject: [PATCH 19/24] Set dev environment --- .do/deploy.template.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 2b4f6f421..70f82ef41 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -4,8 +4,7 @@ spec: - environment_slug: ruby-on-rails envs: - key: RAILS_ENV - value: production - scope: RUN_TIME + value: development - key: RAILS_SERVE_STATIC_FILES value: enabled scope: RUN_TIME From 0755a8cce284822f3d3002b261b5f7a7c3966d9b Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 4 Apr 2024 18:07:51 +0800 Subject: [PATCH 20/24] Set cable production to async and revert to prod env --- .do/deploy.template.yaml | 3 ++- config/cable.yml | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 70f82ef41..2b4f6f421 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -4,7 +4,8 @@ spec: - environment_slug: ruby-on-rails envs: - key: RAILS_ENV - value: development + value: production + scope: RUN_TIME - key: RAILS_SERVE_STATIC_FILES value: enabled scope: RUN_TIME diff --git a/config/cable.yml b/config/cable.yml index 191a39616..fd2d04e89 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -5,6 +5,4 @@ test: adapter: test production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: dradispro_production + adapter: async From 5c8596bd922f496abe270ed7210139fbe8a9a208 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 4 Apr 2024 19:26:23 +0800 Subject: [PATCH 21/24] Remove unused procfile --- Procfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Procfile diff --git a/Procfile b/Procfile deleted file mode 100644 index d307e657a..000000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: bundle exec unicorn -p 5432 From ac44e916fda92794a83e7d166533c6e551f96efa Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 4 Apr 2024 19:41:05 +0800 Subject: [PATCH 22/24] Test remove matrix --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 47d939706..135bb55cd 100644 --- a/Gemfile +++ b/Gemfile @@ -139,8 +139,6 @@ gem 'net-smtp' gem 'net-pop' gem 'net-imap' -gem 'matrix' - gem 'puma', '>= 6.4.2' # ------------------------------------------------------------------ Deployment From 18a4400270bcd880a73e1c448f1d29f1cc6f2a49 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Fri, 5 Apr 2024 14:19:57 +0800 Subject: [PATCH 23/24] Move initializer to dradis-plugins and improve cable.yml parity with pro --- .do/deploy.template.yaml | 2 -- Gemfile | 2 +- Gemfile.lock | 4 ++-- config/cable.yml | 7 +++++-- config/initializers/_preprovision_database.rb | 21 ------------------- 5 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 config/initializers/_preprovision_database.rb diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 2b4f6f421..cc30cf531 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -9,8 +9,6 @@ spec: - key: RAILS_SERVE_STATIC_FILES value: enabled scope: RUN_TIME - - key: HEROKU_DEBUG_RAILS_RUNNER - value: '1' git: branch: fix-heroku-1-click repo_clone_url: https://github.com/dradis/dradis-ce.git diff --git a/Gemfile b/Gemfile index 135bb55cd..77e33aed9 100644 --- a/Gemfile +++ b/Gemfile @@ -213,7 +213,7 @@ end # # Base framework classes required by other plugins -gem 'dradis-plugins', github: 'dradis/dradis-plugins', branch: 'fix/template-caching' +gem 'dradis-plugins', github: 'dradis/dradis-plugins', branch: 'do/add-preprovision-db' gem 'dradis-api', path: 'engines/dradis-api' diff --git a/Gemfile.lock b/Gemfile.lock index fa8383c98..d3ba12e6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/dradis/dradis-plugins.git - revision: e69d1f42c85f647662307019b8b492152a5c3c29 - branch: fix/template-caching + revision: 3d7ab379ee8c12c22020746222d4998e128f2c17 + branch: do/add-preprovision-db specs: dradis-plugins (4.11.0) diff --git a/config/cable.yml b/config/cable.yml index fd2d04e89..fdfd49f35 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,8 +1,11 @@ development: - adapter: async + adapter: <%= defined?(Dradis::Pro) ? 'redis' : 'async' %> + url: <%= ENV.fetch('REDIS_URL') { 'redis://localhost:6379/1' } %> test: adapter: test production: - adapter: async + adapter: <%= defined?(Dradis::Pro) ? 'redis' : 'async' %> + url: <%= ENV.fetch('REDIS_URL') { 'redis://localhost:6379/1' } %> + channel_prefix: dradispro_production diff --git a/config/initializers/_preprovision_database.rb b/config/initializers/_preprovision_database.rb deleted file mode 100644 index a85cfaacf..000000000 --- a/config/initializers/_preprovision_database.rb +++ /dev/null @@ -1,21 +0,0 @@ -# In App Platforms, assets:precompile is run before the DB is provisioned causing a -# ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", -# port 5432 failed: Connection refused -# -# We run into this problem because dradis-plugins uses a :enabled/disabled DB -# setting for each integration to decide whether to load them or not. -# -# See: -# https://devcenter.heroku.com/articles/rails-asset-pipeline -# - -Rails.application.reloader.to_prepare do - # This is set by the App Platforms - if ENV['DATABASE_URL'] - # DB isn't ready yet - if !(ActiveRecord::Base.connection rescue false) - # Empty the list of integrations. - Dradis::Plugins::class_variable_set('@@enabled_list', []) - end - end -end From 35971b97fc69c676206a6539007cfa60e3a9e05f Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Thu, 11 Apr 2024 15:15:48 +0800 Subject: [PATCH 24/24] Use memory_store --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 651599da2..a79bf78b0 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -59,7 +59,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :memory_store, { size: 64.megabytes } # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque