Skip to content

Commit 7ac960b

Browse files
authored
Install capistrano gems (#144)
* Install capistrano gems * Bump actions/setup-node from v2 to v3 * Include Capfile, config/deploy.rb, and config/deploy/production.rb
1 parent 08f4365 commit 7ac960b

File tree

7 files changed

+235
-3
lines changed

7 files changed

+235
-3
lines changed

.github/workflows/decidim_ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
ruby-version: ${{ env.RUBY_VERSION }}
3737
bundler-cache: true
3838
- uses: nanasess/setup-chromedriver@v2
39-
- uses: actions/setup-node@v2
39+
- uses: actions/setup-node@v3
4040
with:
4141
node-version: ${{ env.NODE_VERSION }}
4242
cache: 'npm'

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public/assets
2929
# Ignore webpack packs and related files
3030
public/decidim-packs
3131
public/packs-test
32-
public/sw.js
33-
public/sw.js.map
32+
public/sw.js*
33+
public/sw.js.map*
3434

3535
# Ignore NPM/yarn logs and temp files
3636
.yarn-integrity

Capfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
# Load DSL and set up stages
4+
require "capistrano/setup"
5+
6+
# Include default deployment tasks
7+
require "capistrano/deploy"
8+
9+
# Load the SCM plugin appropriate to your project:
10+
#
11+
# require "capistrano/scm/hg"
12+
# install_plugin Capistrano::SCM::Hg
13+
# or
14+
# require "capistrano/scm/svn"
15+
# install_plugin Capistrano::SCM::Svn
16+
# or
17+
require "capistrano/scm/git"
18+
install_plugin Capistrano::SCM::Git
19+
20+
# Include tasks from other gems included in your Gemfile
21+
#
22+
# For documentation on these, see for example:
23+
#
24+
# https://github.com/capistrano/rvm
25+
# https://github.com/capistrano/rbenv
26+
# https://github.com/capistrano/chruby
27+
# https://github.com/capistrano/bundler
28+
# https://github.com/capistrano/rails
29+
# https://github.com/capistrano/passenger
30+
#
31+
# require "capistrano/rvm"
32+
require "capistrano/rbenv"
33+
# require "capistrano/chruby"
34+
require "capistrano/bundler"
35+
require "capistrano/puma"
36+
require "capistrano/rails/assets"
37+
require "capistrano/rails/migrations"
38+
require "capistrano/rails/console"
39+
require "capistrano/sidekiq"
40+
install_plugin Capistrano::Sidekiq # Default sidekiq tasks
41+
install_plugin Capistrano::Sidekiq::Systemd # Systemd integration
42+
install_plugin Capistrano::Puma
43+
install_plugin Capistrano::Puma::Systemd
44+
45+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
46+
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ group :development do
3535
gem "letter_opener_web"
3636
gem "listen", "~> 3.7.1"
3737
gem "web-console"
38+
39+
gem "capistrano"
40+
gem "capistrano3-puma", "~> 6.0"
41+
gem "capistrano-bundler"
42+
gem "capistrano-passenger"
43+
gem "capistrano-rails"
44+
gem "capistrano-rails-console"
45+
gem "capistrano-rbenv"
46+
gem "capistrano-sidekiq"
3847
end
3948

4049
group :production do

Gemfile.lock

+50
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ GEM
7474
activesupport (>= 6.1)
7575
addressable (2.8.7)
7676
public_suffix (>= 2.0.2, < 7.0)
77+
airbrussh (1.5.3)
78+
sshkit (>= 1.6.1, != 1.7.0)
7779
ast (2.4.2)
7880
aws-eventstream (1.3.0)
7981
aws-partitions (1.972.0)
@@ -112,6 +114,32 @@ GEM
112114
activesupport (>= 3.0.0)
113115
uniform_notifier (~> 1.11)
114116
byebug (11.1.3)
117+
capistrano (3.19.2)
118+
airbrussh (>= 1.0.0)
119+
i18n
120+
rake (>= 10.0.0)
121+
sshkit (>= 1.9.0)
122+
capistrano-bundler (2.1.1)
123+
capistrano (~> 3.1)
124+
capistrano-passenger (0.2.1)
125+
capistrano (~> 3.0)
126+
capistrano-rails (1.7.0)
127+
capistrano (~> 3.1)
128+
capistrano-bundler (>= 1.1, < 3)
129+
capistrano-rails-console (2.3.0)
130+
capistrano (>= 3.5.0, < 4.0.0)
131+
sshkit-interactive (~> 0.3.0)
132+
capistrano-rbenv (2.2.0)
133+
capistrano (~> 3.1)
134+
sshkit (~> 1.3)
135+
capistrano-sidekiq (3.0.0)
136+
capistrano (>= 3.9.0)
137+
capistrano-bundler
138+
sidekiq (>= 6.0.6)
139+
capistrano3-puma (6.0.0)
140+
capistrano (~> 3.7)
141+
capistrano-bundler
142+
puma (>= 5.1, < 7.0)
115143
capybara (3.40.0)
116144
addressable
117145
matrix
@@ -559,8 +587,13 @@ GEM
559587
net-protocol
560588
net-protocol (0.2.2)
561589
timeout
590+
net-scp (4.1.0)
591+
net-ssh (>= 2.6.5, < 8.0.0)
592+
net-sftp (4.0.0)
593+
net-ssh (>= 5.0.0, < 8.0.0)
562594
net-smtp (0.5.1)
563595
net-protocol
596+
net-ssh (7.3.0)
564597
nio4r (2.7.3)
565598
nokogiri (1.16.7-aarch64-linux)
566599
racc (~> 1.4)
@@ -850,6 +883,15 @@ GEM
850883
spring-watcher-listen (2.1.0)
851884
listen (>= 2.7, < 4.0)
852885
spring (>= 4)
886+
sshkit (1.24.0)
887+
base64
888+
logger
889+
net-scp (>= 1.1.2)
890+
net-sftp (>= 2.1.2)
891+
net-ssh (>= 2.8.0)
892+
ostruct
893+
sshkit-interactive (0.3.0)
894+
sshkit (~> 1.12)
853895
statsd-ruby (1.5.0)
854896
strscan (3.1.2)
855897
temple (0.10.3)
@@ -924,6 +966,14 @@ DEPENDENCIES
924966
aws-sdk-s3
925967
barnes
926968
byebug
969+
capistrano
970+
capistrano-bundler
971+
capistrano-passenger
972+
capistrano-rails
973+
capistrano-rails-console
974+
capistrano-rbenv
975+
capistrano-sidekiq
976+
capistrano3-puma (~> 6.0)
927977
dalli
928978
decidim (= 0.30.0.rc3)
929979
decidim-conferences (= 0.30.0.rc3)

config/deploy.rb

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# frozen_string_literal: true
2+
3+
# config valid for current version and patch releases of Capistrano
4+
lock "~> 3.19.2"
5+
6+
SSHKit.config.command_map[:sidekiq] = 'bundle exec sidekiq'
7+
SSHKit.config.command_map[:sidekiqctl] = 'bundle exec sidekiqctl'
8+
9+
set :rbenv_type, :user
10+
set :rbenv_ruby, '3.3.4'
11+
12+
set :application, "metadecidim"
13+
set :repo_url, "https://github.com/decidim/metadecidim.git"
14+
15+
# Default branch is :master
16+
set :branch, `git rev-parse --abbrev-ref HEAD`.chomp
17+
18+
# Default deploy_to directory is /var/www/my_app_name
19+
set :deploy_to, "/home/ubuntu/decidim"
20+
21+
# Default value for :format is :airbrussh.
22+
# set :format, :airbrussh
23+
24+
# You can configure the Airbrussh format using :format_options.
25+
# These are the defaults.
26+
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
27+
28+
# Default value for :pty is false
29+
# set :pty, true
30+
31+
# Default value for :linked_files is []
32+
append :linked_files, ".rbenv-vars"
33+
34+
# Default value for linked_dirs is []
35+
append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system", "vendor/bundle", "public/uploads", "storage"
36+
37+
# Default value for default_env is {}
38+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
39+
40+
# Default value for local_user is ENV['USER']
41+
# set :local_user, -> { `git config user.name`.chomp }
42+
43+
# Default value for keep_releases is 5
44+
# set :keep_releases, 5
45+
46+
# Uncomment the following to require manually verifying the host key before first deploy.
47+
# set :ssh_options, verify_host_key: :secure
48+
49+
set :bundle_path, nil
50+
set :bundle_flags, nil
51+
52+
Rake::Task['deploy:assets:backup_manifest'].clear_actions
53+
Rake::Task['deploy:assets:restore_manifest'].clear_actions
54+
55+
namespace :deploy do
56+
desc 'Decidim webpacker configuration'
57+
task :decidim_webpacker_install do
58+
on roles(:all) do
59+
within release_path do
60+
execute :'. ~/.nvm/nvm.sh'
61+
execute 'npm', 'ci'
62+
end
63+
end
64+
end
65+
66+
before 'deploy:assets:precompile', 'deploy:decidim_webpacker_install'
67+
end

config/deploy/production.rb

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# frozen_string_literal: true
2+
3+
# server-based syntax
4+
# ======================
5+
# Defines a single server with a list of roles and multiple properties.
6+
# You can define all roles on a single server, or split them:
7+
8+
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
9+
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
10+
# server "db.example.com", user: "deploy", roles: %w{db}
11+
12+
server ENV["PRODUCTION_SERVER"], user: ENV["PRODUCTION_USER"], roles: %w{app db web worker}
13+
14+
# role-based syntax
15+
# ==================
16+
17+
# Defines a role with one or multiple servers. The primary server in each
18+
# group is considered to be the first unless any hosts have the primary
19+
# property set. Specify the username and a domain or IP for the server.
20+
# Don't use `:all`, it's a meta role.
21+
22+
# role :app, %w{[email protected]}, my_property: :my_value
23+
# role :web, %w{[email protected] [email protected]}, other_property: :other_value
24+
# role :db, %w{[email protected]}
25+
26+
# Configuration
27+
# =============
28+
# You can set any configuration variable like in config/deploy.rb
29+
# These variables are then only loaded and set in this stage.
30+
# For available Capistrano configuration variables see the documentation page.
31+
# http://capistranorb.com/documentation/getting-started/configuration/
32+
# Feel free to add new variables to customise your setup.
33+
34+
# Custom SSH Options
35+
# ==================
36+
# You may pass any option but keep in mind that net/ssh understands a
37+
# limited set of options, consult the Net::SSH documentation.
38+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
39+
#
40+
# Global options
41+
# --------------
42+
43+
set :rails_env, 'production'
44+
45+
set :ssh_options, {
46+
verify_host_key: :never
47+
}
48+
49+
# The server-based syntax can be used to override options:
50+
# ------------------------------------
51+
# server "example.com",
52+
# user: "user_name",
53+
# roles: %w{web app},
54+
# ssh_options: {
55+
# user: "user_name", # overrides user setting above
56+
# keys: %w(/home/user_name/.ssh/id_rsa),
57+
# forward_agent: false,
58+
# auth_methods: %w(publickey password)
59+
# # password: "please use keys"
60+
# }

0 commit comments

Comments
 (0)