From 292538564126e8a342dc79ebf06c6e926125685d Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 27 Feb 2023 16:28:51 -0500 Subject: [PATCH 01/13] Install capistrano for imagecat --- Capfile | 38 +++++++++++++++++++++++ Gemfile | 1 + Gemfile.lock | 14 +++++++++ config/deploy.rb | 41 +++++++++++++++++++++++++ config/deploy/production.rb | 61 +++++++++++++++++++++++++++++++++++++ config/deploy/staging.rb | 61 +++++++++++++++++++++++++++++++++++++ 6 files changed, 216 insertions(+) create mode 100644 Capfile create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb create mode 100644 config/deploy/staging.rb diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..42dd3a4 --- /dev/null +++ b/Capfile @@ -0,0 +1,38 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Load the SCM plugin appropriate to your project: +# +# require "capistrano/scm/hg" +# install_plugin Capistrano::SCM::Hg +# or +# require "capistrano/scm/svn" +# install_plugin Capistrano::SCM::Svn +# or +require "capistrano/scm/git" +install_plugin Capistrano::SCM::Git + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require "capistrano/rvm" +# require "capistrano/rbenv" +# require "capistrano/chruby" +# require "capistrano/bundler" +# require "capistrano/rails/assets" +# require "capistrano/rails/migrations" +# require "capistrano/passenger" + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/Gemfile b/Gemfile index b6bc534..57daca1 100644 --- a/Gemfile +++ b/Gemfile @@ -55,6 +55,7 @@ group :development, :test do gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rspec-rails' gem 'rubocop-rails', require: false + gem 'capistrano', require: false end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index fcb1b93..a43aa4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,11 +66,18 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) + airbrussh (1.4.1) + sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) + capistrano (3.17.2) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) concurrent-ruby (1.2.0) crass (1.0.6) date (3.3.3) @@ -113,8 +120,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.3.3) net-protocol + net-ssh (7.0.1) nio4r (2.5.8) nokogiri (1.14.1-arm64-darwin) racc (~> 1.4) @@ -201,6 +211,9 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sshkit (1.21.4) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) stimulus-rails (1.2.1) railties (>= 6.0.0) thor (1.2.1) @@ -227,6 +240,7 @@ PLATFORMS DEPENDENCIES bootsnap + capistrano debug importmap-rails jbuilder diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..113cf4c --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,41 @@ +# config valid for current version and patch releases of Capistrano +lock "~> 3.17.2" + +set :application, "my_app_name" +set :repo_url, "git@example.com:me/my_repo.git" + +set :branch, ENV["BRANCH"] || "main" + +# Default branch is :master +# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp + +# Default deploy_to directory is /var/www/my_app_name +# set :deploy_to, "/var/www/my_app_name" + +# Default value for :format is :airbrussh. +# set :format, :airbrussh + +# You can configure the Airbrussh format using :format_options. +# These are the defaults. +# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto + +# Default value for :pty is false +# set :pty, true + +# Default value for :linked_files is [] +# append :linked_files, "config/database.yml", 'config/master.key' + +# Default value for linked_dirs is [] +# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", "vendor", "storage" + +# Default value for default_env is {} +# set :default_env, { path: "/opt/ruby/bin:$PATH" } + +# Default value for local_user is ENV['USER'] +# set :local_user, -> { `git config user.name`.chomp } + +# Default value for keep_releases is 5 +# set :keep_releases, 5 + +# Uncomment the following to require manually verifying the host key before first deploy. +# set :ssh_options, verify_host_key: :secure diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..0a3f086 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,61 @@ +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value +# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value +# server "db.example.com", user: "deploy", roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# Configuration +# ============= +# You can set any configuration variable like in config/deploy.rb +# These variables are then only loaded and set in this stage. +# For available Capistrano configuration variables see the documentation page. +# http://capistranorb.com/documentation/getting-started/configuration/ +# Feel free to add new variables to customise your setup. + + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult the Net::SSH documentation. +# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# The server-based syntax can be used to override options: +# ------------------------------------ +# server "example.com", +# user: "user_name", +# roles: %w{web app}, +# ssh_options: { +# user: "user_name", # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: "please use keys" +# } diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..0a3f086 --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,61 @@ +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value +# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value +# server "db.example.com", user: "deploy", roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# Configuration +# ============= +# You can set any configuration variable like in config/deploy.rb +# These variables are then only loaded and set in this stage. +# For available Capistrano configuration variables see the documentation page. +# http://capistranorb.com/documentation/getting-started/configuration/ +# Feel free to add new variables to customise your setup. + + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult the Net::SSH documentation. +# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# The server-based syntax can be used to override options: +# ------------------------------------ +# server "example.com", +# user: "user_name", +# roles: %w{web app}, +# ssh_options: { +# user: "user_name", # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: "please use keys" +# } From b64d7dd078b59492e9507a3e680c525085aa0b1a Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 27 Feb 2023 16:33:40 -0500 Subject: [PATCH 02/13] Rubocop corrections for capistrano install --- Capfile | 10 ++++++---- Gemfile | 2 +- config/deploy.rb | 10 ++++++---- config/deploy/production.rb | 7 +------ config/deploy/staging.rb | 7 +------ 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Capfile b/Capfile index 42dd3a4..60c47d7 100644 --- a/Capfile +++ b/Capfile @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # Load DSL and set up stages -require "capistrano/setup" +require 'capistrano/setup' # Include default deployment tasks -require "capistrano/deploy" +require 'capistrano/deploy' # Load the SCM plugin appropriate to your project: # @@ -12,7 +14,7 @@ require "capistrano/deploy" # require "capistrano/scm/svn" # install_plugin Capistrano::SCM::Svn # or -require "capistrano/scm/git" +require 'capistrano/scm/git' install_plugin Capistrano::SCM::Git # Include tasks from other gems included in your Gemfile @@ -35,4 +37,4 @@ install_plugin Capistrano::SCM::Git # require "capistrano/passenger" # Load custom tasks from `lib/capistrano/tasks` if you have any defined -Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 57daca1..a81b206 100644 --- a/Gemfile +++ b/Gemfile @@ -52,10 +52,10 @@ gem 'bootsnap', require: false group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem 'capistrano', require: false gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rspec-rails' gem 'rubocop-rails', require: false - gem 'capistrano', require: false end group :development do diff --git a/config/deploy.rb b/config/deploy.rb index 113cf4c..dd93f63 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # config valid for current version and patch releases of Capistrano -lock "~> 3.17.2" +lock '~> 3.17.2' -set :application, "my_app_name" -set :repo_url, "git@example.com:me/my_repo.git" +set :application, 'my_app_name' +set :repo_url, 'git@example.com:me/my_repo.git' -set :branch, ENV["BRANCH"] || "main" +set :branch, ENV['BRANCH'] || 'main' # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 0a3f086..a0ea5a4 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # server-based syntax # ====================== # Defines a single server with a list of roles and multiple properties. @@ -7,8 +8,6 @@ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value # server "db.example.com", user: "deploy", roles: %w{db} - - # role-based syntax # ================== @@ -21,8 +20,6 @@ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value # role :db, %w{deploy@example.com} - - # Configuration # ============= # You can set any configuration variable like in config/deploy.rb @@ -31,8 +28,6 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. - - # Custom SSH Options # ================== # You may pass any option but keep in mind that net/ssh understands a diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 0a3f086..a0ea5a4 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # server-based syntax # ====================== # Defines a single server with a list of roles and multiple properties. @@ -7,8 +8,6 @@ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value # server "db.example.com", user: "deploy", roles: %w{db} - - # role-based syntax # ================== @@ -21,8 +20,6 @@ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value # role :db, %w{deploy@example.com} - - # Configuration # ============= # You can set any configuration variable like in config/deploy.rb @@ -31,8 +28,6 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. - - # Custom SSH Options # ================== # You may pass any option but keep in mind that net/ssh understands a From b9b753f8c66e526975c5d700d410894a56bd6987 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Tue, 28 Feb 2023 10:46:43 -0500 Subject: [PATCH 03/13] rubocop updates --- config/deploy.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index dd93f63..968b695 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -28,7 +28,8 @@ # append :linked_files, "config/database.yml", 'config/master.key' # Default value for linked_dirs is [] -# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", "vendor", "storage" +# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", +# "vendor", "storage" # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } From acf873d5125251792cfe1f4b86476faf7511e710 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Tue, 28 Feb 2023 14:58:46 -0500 Subject: [PATCH 04/13] update deploy.rb file --- config/deploy.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 968b695..de4fe9f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -3,16 +3,16 @@ # config valid for current version and patch releases of Capistrano lock '~> 3.17.2' -set :application, 'my_app_name' -set :repo_url, 'git@example.com:me/my_repo.git' +set :application, 'imagecat_rails' +set :repo_url, 'https://github.com/pulibrary/imagecat-rails' set :branch, ENV['BRANCH'] || 'main' # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp -# Default deploy_to directory is /var/www/my_app_name -# set :deploy_to, "/var/www/my_app_name" +# Default deploy_to directory is /var/www/imagecat_rails +# set :deploy_to, "/var/www/imagecat_rails" # Default value for :format is :airbrussh. # set :format, :airbrussh @@ -28,7 +28,7 @@ # append :linked_files, "config/database.yml", 'config/master.key' # Default value for linked_dirs is [] -# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", +# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", # "vendor", "storage" # Default value for default_env is {} From c7449a1b0192dfbeb0dfb7f6407463f3d33d7c6c Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 12:30:06 -0500 Subject: [PATCH 05/13] Configure capistrano for imagecat Co-authored-by: Bess Sadler --- Capfile | 3 ++- Gemfile | 2 ++ Gemfile.lock | 9 +++++++ config/deploy.rb | 37 +++----------------------- config/deploy/staging.rb | 56 +--------------------------------------- 5 files changed, 17 insertions(+), 90 deletions(-) diff --git a/Capfile b/Capfile index 60c47d7..6bc0166 100644 --- a/Capfile +++ b/Capfile @@ -5,6 +5,7 @@ require 'capistrano/setup' # Include default deployment tasks require 'capistrano/deploy' +require 'capistrano/rails' # Load the SCM plugin appropriate to your project: # @@ -34,7 +35,7 @@ install_plugin Capistrano::SCM::Git # require "capistrano/bundler" # require "capistrano/rails/assets" # require "capistrano/rails/migrations" -# require "capistrano/passenger" +require "capistrano/passenger" # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index a81b206..ee69941 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,8 @@ gem 'bootsnap', require: false group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem 'capistrano', require: false + gem "capistrano-passenger", require: false + gem "capistrano-rails", "~> 1.4", require: false gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rspec-rails' gem 'rubocop-rails', require: false diff --git a/Gemfile.lock b/Gemfile.lock index a43aa4b..71c3f3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,6 +78,13 @@ GEM i18n rake (>= 10.0.0) sshkit (>= 1.9.0) + capistrano-bundler (2.1.0) + capistrano (~> 3.1) + capistrano-passenger (0.2.1) + capistrano (~> 3.0) + capistrano-rails (1.6.2) + capistrano (~> 3.1) + capistrano-bundler (>= 1.1, < 3) concurrent-ruby (1.2.0) crass (1.0.6) date (3.3.3) @@ -241,6 +248,8 @@ PLATFORMS DEPENDENCIES bootsnap capistrano + capistrano-passenger + capistrano-rails (~> 1.4) debug importmap-rails jbuilder diff --git a/config/deploy.rb b/config/deploy.rb index de4fe9f..c151a49 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -6,39 +6,8 @@ set :application, 'imagecat_rails' set :repo_url, 'https://github.com/pulibrary/imagecat-rails' -set :branch, ENV['BRANCH'] || 'main' - -# Default branch is :master -# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp - -# Default deploy_to directory is /var/www/imagecat_rails -# set :deploy_to, "/var/www/imagecat_rails" - -# Default value for :format is :airbrussh. -# set :format, :airbrussh - -# You can configure the Airbrussh format using :format_options. -# These are the defaults. -# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto - -# Default value for :pty is false -# set :pty, true +set :linked_dirs, %w[log public/system public/assets] -# Default value for :linked_files is [] -# append :linked_files, "config/database.yml", 'config/master.key' - -# Default value for linked_dirs is [] -# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", -# "vendor", "storage" - -# Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } - -# Default value for local_user is ENV['USER'] -# set :local_user, -> { `git config user.name`.chomp } - -# Default value for keep_releases is 5 -# set :keep_releases, 5 +set :branch, ENV['BRANCH'] || 'main' -# Uncomment the following to require manually verifying the host key before first deploy. -# set :ssh_options, verify_host_key: :secure +set :deploy_to, "/opt/imagecat_rails" \ No newline at end of file diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index a0ea5a4..b929d02 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,56 +1,2 @@ # frozen_string_literal: true -# server-based syntax -# ====================== -# Defines a single server with a list of roles and multiple properties. -# You can define all roles on a single server, or split them: - -# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value -# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value -# server "db.example.com", user: "deploy", roles: %w{db} - -# role-based syntax -# ================== - -# Defines a role with one or multiple servers. The primary server in each -# group is considered to be the first unless any hosts have the primary -# property set. Specify the username and a domain or IP for the server. -# Don't use `:all`, it's a meta role. - -# role :app, %w{deploy@example.com}, my_property: :my_value -# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value -# role :db, %w{deploy@example.com} - -# Configuration -# ============= -# You can set any configuration variable like in config/deploy.rb -# These variables are then only loaded and set in this stage. -# For available Capistrano configuration variables see the documentation page. -# http://capistranorb.com/documentation/getting-started/configuration/ -# Feel free to add new variables to customise your setup. - -# Custom SSH Options -# ================== -# You may pass any option but keep in mind that net/ssh understands a -# limited set of options, consult the Net::SSH documentation. -# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start -# -# Global options -# -------------- -# set :ssh_options, { -# keys: %w(/home/user_name/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(password) -# } -# -# The server-based syntax can be used to override options: -# ------------------------------------ -# server "example.com", -# user: "user_name", -# roles: %w{web app}, -# ssh_options: { -# user: "user_name", # overrides user setting above -# keys: %w(/home/user_name/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(publickey password) -# # password: "please use keys" -# } +server "imagecat-staging1.princeton.edu", user: "deploy", roles: %w[app db web] \ No newline at end of file From dd035c669c8aac424568760734a5398d72e9a867 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 12:34:37 -0500 Subject: [PATCH 06/13] add x86_64-linux to Gemfile.lock --- Gemfile.lock | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 71c3f3a..f72c05e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,8 @@ GEM nio4r (2.5.8) nokogiri (1.14.1-arm64-darwin) racc (~> 1.4) + nokogiri (1.14.1-x86_64-linux) + racc (~> 1.4) parallel (1.22.1) parser (3.2.1.0) ast (~> 2.4.1) @@ -244,6 +246,7 @@ GEM PLATFORMS arm64-darwin-21 + x86_64-linux DEPENDENCIES bootsnap From 0fae1daceda028559c5094bf7fc4adbb86508d69 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 12:43:18 -0500 Subject: [PATCH 07/13] add staging environment file --- config/environments/staging.rb | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 config/environments/staging.rb diff --git a/config/environments/staging.rb b/config/environments/staging.rb new file mode 100644 index 0000000..ceeef86 --- /dev/null +++ b/config/environments/staging.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + 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). + # 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? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # 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 + + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] + + # 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 = "imagecat_rails_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # 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 + + # 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 + + # 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 +end From 231a82aa3f1c9c78606cbfc990774ef2f6cf1ed1 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 15:21:39 -0500 Subject: [PATCH 08/13] placeholder --- config/routes.rb | 3 ++- public/placeholder.html | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 public/placeholder.html diff --git a/config/routes.rb b/config/routes.rb index 7b329f5..78b9390 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,6 @@ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") - # root "articles#index" + # root static("placeholder.html") + get '/', :to => redirect('placeholder.html') end diff --git a/public/placeholder.html b/public/placeholder.html new file mode 100644 index 0000000..13235f4 --- /dev/null +++ b/public/placeholder.html @@ -0,0 +1,6 @@ + + + placeholder + + + \ No newline at end of file From d35ad0796b0e9dd7d19eb259fce570d61899f896 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 15:51:16 -0500 Subject: [PATCH 09/13] deploy to production --- config/deploy/production.rb | 56 +------------------------------------ 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/config/deploy/production.rb b/config/deploy/production.rb index a0ea5a4..e7fa2bd 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,56 +1,2 @@ # frozen_string_literal: true -# server-based syntax -# ====================== -# Defines a single server with a list of roles and multiple properties. -# You can define all roles on a single server, or split them: - -# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value -# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value -# server "db.example.com", user: "deploy", roles: %w{db} - -# role-based syntax -# ================== - -# Defines a role with one or multiple servers. The primary server in each -# group is considered to be the first unless any hosts have the primary -# property set. Specify the username and a domain or IP for the server. -# Don't use `:all`, it's a meta role. - -# role :app, %w{deploy@example.com}, my_property: :my_value -# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value -# role :db, %w{deploy@example.com} - -# Configuration -# ============= -# You can set any configuration variable like in config/deploy.rb -# These variables are then only loaded and set in this stage. -# For available Capistrano configuration variables see the documentation page. -# http://capistranorb.com/documentation/getting-started/configuration/ -# Feel free to add new variables to customise your setup. - -# Custom SSH Options -# ================== -# You may pass any option but keep in mind that net/ssh understands a -# limited set of options, consult the Net::SSH documentation. -# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start -# -# Global options -# -------------- -# set :ssh_options, { -# keys: %w(/home/user_name/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(password) -# } -# -# The server-based syntax can be used to override options: -# ------------------------------------ -# server "example.com", -# user: "user_name", -# roles: %w{web app}, -# ssh_options: { -# user: "user_name", # overrides user setting above -# keys: %w(/home/user_name/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(publickey password) -# # password: "please use keys" -# } +server "imagecat-prod1.princeton.edu", user: "deploy", roles: %w[app db web] \ No newline at end of file From 9d12904143a490d5ab1e687d3e6e6aeb7420edf4 Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Mon, 6 Mar 2023 15:52:00 -0500 Subject: [PATCH 10/13] style fixes --- Capfile | 2 +- Gemfile | 4 ++-- config/deploy.rb | 2 +- config/deploy/production.rb | 3 ++- config/deploy/staging.rb | 3 ++- config/routes.rb | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Capfile b/Capfile index 6bc0166..9ef75d1 100644 --- a/Capfile +++ b/Capfile @@ -35,7 +35,7 @@ install_plugin Capistrano::SCM::Git # require "capistrano/bundler" # require "capistrano/rails/assets" # require "capistrano/rails/migrations" -require "capistrano/passenger" +require 'capistrano/passenger' # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index ee69941..c6b50dd 100644 --- a/Gemfile +++ b/Gemfile @@ -53,8 +53,8 @@ gem 'bootsnap', require: false group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem 'capistrano', require: false - gem "capistrano-passenger", require: false - gem "capistrano-rails", "~> 1.4", require: false + gem 'capistrano-passenger', require: false + gem 'capistrano-rails', '~> 1.4', require: false gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'rspec-rails' gem 'rubocop-rails', require: false diff --git a/config/deploy.rb b/config/deploy.rb index c151a49..b0365e4 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -10,4 +10,4 @@ set :branch, ENV['BRANCH'] || 'main' -set :deploy_to, "/opt/imagecat_rails" \ No newline at end of file +set :deploy_to, '/opt/imagecat_rails' diff --git a/config/deploy/production.rb b/config/deploy/production.rb index e7fa2bd..0fba97d 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,2 +1,3 @@ # frozen_string_literal: true -server "imagecat-prod1.princeton.edu", user: "deploy", roles: %w[app db web] \ No newline at end of file + +server 'imagecat-prod1.princeton.edu', user: 'deploy', roles: %w[app db web] diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index b929d02..1182d6f 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,2 +1,3 @@ # frozen_string_literal: true -server "imagecat-staging1.princeton.edu", user: "deploy", roles: %w[app db web] \ No newline at end of file + +server 'imagecat-staging1.princeton.edu', user: 'deploy', roles: %w[app db web] diff --git a/config/routes.rb b/config/routes.rb index 78b9390..9f8687c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,6 @@ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") - # root static("placeholder.html") - get '/', :to => redirect('placeholder.html') + # root static("placeholder.html") + get '/', to: redirect('placeholder.html') end From 9c9f5fa88656658c1bb3d53e7974e30578940d83 Mon Sep 17 00:00:00 2001 From: Bess Sadler Date: Mon, 6 Mar 2023 18:33:45 -0500 Subject: [PATCH 11/13] Regenerate Gemfile.lock --- Gemfile.lock | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index f72c05e..1cba2c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,8 @@ GEM nio4r (2.5.8) nokogiri (1.14.1-arm64-darwin) racc (~> 1.4) + nokogiri (1.14.1-x86_64-darwin) + racc (~> 1.4) nokogiri (1.14.1-x86_64-linux) racc (~> 1.4) parallel (1.22.1) @@ -246,6 +248,7 @@ GEM PLATFORMS arm64-darwin-21 + x86_64-darwin-22 x86_64-linux DEPENDENCIES From bae632f5e6918ee5b09c109f6395b6130e281b8f Mon Sep 17 00:00:00 2001 From: Bess Sadler Date: Mon, 6 Mar 2023 18:34:44 -0500 Subject: [PATCH 12/13] Temporarily removing Gemfile.lock --- Gemfile.lock | 277 --------------------------------------------------- 1 file changed, 277 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 1cba2c5..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,277 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.0.4.2) - actionpack (= 7.0.4.2) - activesupport (= 7.0.4.2) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.2) - actionpack (= 7.0.4.2) - activejob (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.4.2) - actionpack (= 7.0.4.2) - actionview (= 7.0.4.2) - activejob (= 7.0.4.2) - activesupport (= 7.0.4.2) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4.2) - actionview (= 7.0.4.2) - activesupport (= 7.0.4.2) - rack (~> 2.0, >= 2.2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.2) - actionpack (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.0.4.2) - activesupport (= 7.0.4.2) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.2) - activesupport (= 7.0.4.2) - globalid (>= 0.3.6) - activemodel (7.0.4.2) - activesupport (= 7.0.4.2) - activerecord (7.0.4.2) - activemodel (= 7.0.4.2) - activesupport (= 7.0.4.2) - activestorage (7.0.4.2) - actionpack (= 7.0.4.2) - activejob (= 7.0.4.2) - activerecord (= 7.0.4.2) - activesupport (= 7.0.4.2) - marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4.2) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - airbrussh (1.4.1) - sshkit (>= 1.6.1, != 1.7.0) - ast (2.4.2) - bindex (0.8.1) - bootsnap (1.16.0) - msgpack (~> 1.2) - builder (3.2.4) - capistrano (3.17.2) - airbrussh (>= 1.0.0) - i18n - rake (>= 10.0.0) - sshkit (>= 1.9.0) - capistrano-bundler (2.1.0) - capistrano (~> 3.1) - capistrano-passenger (0.2.1) - capistrano (~> 3.0) - capistrano-rails (1.6.2) - capistrano (~> 3.1) - capistrano-bundler (>= 1.1, < 3) - concurrent-ruby (1.2.0) - crass (1.0.6) - date (3.3.3) - debug (1.7.1) - irb (>= 1.5.0) - reline (>= 0.3.1) - diff-lcs (1.5.0) - erubi (1.12.0) - globalid (1.1.0) - activesupport (>= 5.0) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - importmap-rails (1.1.5) - actionpack (>= 6.0.0) - railties (>= 6.0.0) - io-console (0.6.0) - irb (1.6.2) - reline (>= 0.3.0) - jbuilder (2.11.5) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - json (2.6.3) - loofah (2.19.1) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.8.0.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.2) - method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.17.0) - msgpack (1.6.0) - net-imap (0.3.4) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.1) - timeout - net-scp (4.0.0) - net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.3.3) - net-protocol - net-ssh (7.0.1) - nio4r (2.5.8) - nokogiri (1.14.1-arm64-darwin) - racc (~> 1.4) - nokogiri (1.14.1-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.14.1-x86_64-linux) - racc (~> 1.4) - parallel (1.22.1) - parser (3.2.1.0) - ast (~> 2.4.1) - pg (1.4.5) - puma (5.6.5) - nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.6.2) - rack-test (2.0.2) - rack (>= 1.3) - rails (7.0.4.2) - actioncable (= 7.0.4.2) - actionmailbox (= 7.0.4.2) - actionmailer (= 7.0.4.2) - actionpack (= 7.0.4.2) - actiontext (= 7.0.4.2) - actionview (= 7.0.4.2) - activejob (= 7.0.4.2) - activemodel (= 7.0.4.2) - activerecord (= 7.0.4.2) - activestorage (= 7.0.4.2) - activesupport (= 7.0.4.2) - bundler (>= 1.15.0) - railties (= 7.0.4.2) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.2) - actionpack (= 7.0.4.2) - activesupport (= 7.0.4.2) - method_source - rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.7.0) - reline (0.3.2) - io-console (~> 0.5) - rexml (3.2.5) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.3) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.0.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) - rspec-support (3.12.0) - rubocop (1.45.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.2.0.0) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.24.1, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.26.0) - parser (>= 3.2.1.0) - rubocop-rails (2.17.4) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - ruby-progressbar (1.11.0) - sprockets (4.2.0) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) - sshkit (1.21.4) - net-scp (>= 1.1.2) - net-ssh (>= 2.8.0) - stimulus-rails (1.2.1) - railties (>= 6.0.0) - thor (1.2.1) - timeout (0.3.1) - turbo-rails (1.3.3) - actionpack (>= 6.0.0) - activejob (>= 6.0.0) - railties (>= 6.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) - web-console (4.2.0) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.6.6) - -PLATFORMS - arm64-darwin-21 - x86_64-darwin-22 - x86_64-linux - -DEPENDENCIES - bootsnap - capistrano - capistrano-passenger - capistrano-rails (~> 1.4) - debug - importmap-rails - jbuilder - pg (~> 1.1) - puma (~> 5.0) - rails (~> 7.0.4) - rspec-rails - rubocop-rails - sprockets-rails - stimulus-rails - turbo-rails - tzinfo-data - web-console - -RUBY VERSION - ruby 3.2.0p0 - -BUNDLED WITH - 2.3.7 From b2a5e2521e326d76b04f177c86ed533bd47036ee Mon Sep 17 00:00:00 2001 From: Bess Sadler Date: Mon, 6 Mar 2023 18:37:01 -0500 Subject: [PATCH 13/13] Regenerate Gemfile.lock --- Gemfile.lock | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 1068885..46667ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,12 +66,26 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) + airbrussh (1.4.1) + sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) + capistrano (3.17.2) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (2.1.0) + capistrano (~> 3.1) + capistrano-passenger (0.2.1) + capistrano (~> 3.0) + capistrano-rails (1.6.2) + capistrano (~> 3.1) + capistrano-bundler (>= 1.1, < 3) coderay (1.1.3) concurrent-ruby (1.2.0) coveralls_reborn (0.27.0) @@ -121,8 +135,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.3.3) net-protocol + net-ssh (7.0.1) nio4r (2.5.8) nokogiri (1.14.1-arm64-darwin) racc (~> 1.4) @@ -224,6 +241,9 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sshkit (1.21.4) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) stimulus-rails (1.2.1) railties (>= 6.0.0) sync (0.5.0) @@ -253,9 +273,13 @@ GEM PLATFORMS arm64-darwin-21 x86_64-darwin-20 + x86_64-darwin-22 DEPENDENCIES bootsnap + capistrano + capistrano-passenger + capistrano-rails (~> 1.4) coveralls_reborn (~> 0.27.0) debug importmap-rails