From d0d53bd6e8d9d81dadccaed5009f436ce59fe1a8 Mon Sep 17 00:00:00 2001 From: Christina Chortaria Date: Thu, 28 Sep 2023 17:26:33 -0400 Subject: [PATCH] Deployment with capistrano --- Capfile | 13 +++++++++++++ Gemfile | 5 +++++ Gemfile.lock | 30 ++++++++++++++++++++++++++++++ config/deploy.rb | 33 +++++++++++++++++++++++++++++++++ config/deploy/production.rb | 5 +++++ config/deploy/staging.rb | 5 +++++ 6 files changed, 91 insertions(+) create mode 100644 Capfile create mode 100644 Gemfile create mode 100644 Gemfile.lock 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..97071cc --- /dev/null +++ b/Capfile @@ -0,0 +1,13 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +require "capistrano/scm/git" +install_plugin Capistrano::SCM::Git + +#set :dist, 'dist' + +# 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 new file mode 100644 index 0000000..80eecc1 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +group :development do + gem "capistrano", require: false +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..de07a7a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,30 @@ +GEM + remote: https://rubygems.org/ + specs: + airbrussh (1.5.0) + sshkit (>= 1.6.1, != 1.7.0) + capistrano (3.11.2) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + concurrent-ruby (1.2.2) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.2.0) + rake (13.0.6) + sshkit (1.21.5) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + +PLATFORMS + x86_64-darwin-21 + x86_64-darwin-22 + +DEPENDENCIES + capistrano + +BUNDLED WITH + 2.4.10 diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..64f0cdf --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,33 @@ +# config valid for current version and patch releases of Capistrano +lock "~> 3.17.1" + +set :branch, ENV['BRANCH'] || 'main' + +set :application, "allsearch_frontend" +set :repo_url, "https://github.com/pulibrary/allsearch_frontend.git" + +# 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, "/opt/allsearch_frontend" + +namespace :deploy do + desc "Run yarn install" + task :yarn_install do + on roles(:web) do + within release_path do + execute("cd #{release_path} && yarn install") + end + end + end + desc "Create dist" + task :yarn_build do + on roles(:web) do + within release_path do + execute("cd #{release_path} && yarn build") + end + end + end +end + diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..6901e0a --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,5 @@ +set :stage, :production +set :node_env, 'production' + +server "allsearch-prod1", user: "deploy", roles: %w{app web} +server "allsearch-prod2", user: "deploy", roles: %w{app web} \ No newline at end of file diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..06a3fda --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,5 @@ +set :stage, :staging +set :node_env, 'staging' + +server "allsearch-staging1", user: "deploy", roles: %w{app web} +server "allsearch-staging2", user: "deploy", roles: %w{app web}