From 87901748bbac05e9f0532aa0ed6ed5086f3fb2c0 Mon Sep 17 00:00:00 2001 From: Robert-Anthony Lee-Faison <108823963+leefaisonr@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:40:08 -0500 Subject: [PATCH] Install capistrano for imagecat (#35) Co-authored-by: Bess Sadler --- Capfile | 41 +++++++++++++++ Gemfile | 3 ++ Gemfile.lock | 24 +++++++++ config/deploy.rb | 13 +++++ config/deploy/production.rb | 3 ++ config/deploy/staging.rb | 3 ++ config/environments/staging.rb | 95 ++++++++++++++++++++++++++++++++++ config/routes.rb | 3 +- public/placeholder.html | 6 +++ 9 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 Capfile create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb create mode 100644 config/deploy/staging.rb create mode 100644 config/environments/staging.rb create mode 100644 public/placeholder.html diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..9ef75d1 --- /dev/null +++ b/Capfile @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +# Load DSL and set up stages +require 'capistrano/setup' + +# Include default deployment tasks +require 'capistrano/deploy' +require 'capistrano/rails' + +# 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 763a1f7..3ce1520 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,9 @@ gem 'bootsnap', require: false group :development, :test do gem 'coveralls_reborn', '~> 0.27.0', require: false # 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 'pry' gem 'pry-byebug' 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 diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..b0365e4 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# config valid for current version and patch releases of Capistrano +lock '~> 3.17.2' + +set :application, 'imagecat_rails' +set :repo_url, 'https://github.com/pulibrary/imagecat-rails' + +set :linked_dirs, %w[log public/system public/assets] + +set :branch, ENV['BRANCH'] || 'main' + +set :deploy_to, '/opt/imagecat_rails' diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..0fba97d --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +server 'imagecat-prod1.princeton.edu', user: 'deploy', roles: %w[app db web] diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..1182d6f --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +server 'imagecat-staging1.princeton.edu', user: 'deploy', roles: %w[app db web] 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 diff --git a/config/routes.rb b/config/routes.rb index 7b329f5..9f8687c 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