diff --git a/.github/workflows/decidim_ci.yml b/.github/workflows/decidim_ci.yml index 95eca11f..ca8b390e 100644 --- a/.github/workflows/decidim_ci.yml +++ b/.github/workflows/decidim_ci.yml @@ -36,7 +36,7 @@ jobs: ruby-version: ${{ env.RUBY_VERSION }} bundler-cache: true - uses: nanasess/setup-chromedriver@v2 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' diff --git a/.gitignore b/.gitignore index daf9afd9..02290432 100644 --- a/.gitignore +++ b/.gitignore @@ -29,8 +29,8 @@ public/assets # Ignore webpack packs and related files public/decidim-packs public/packs-test -public/sw.js -public/sw.js.map +public/sw.js* +public/sw.js.map* # Ignore NPM/yarn logs and temp files .yarn-integrity diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..4223dacb --- /dev/null +++ b/Capfile @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +# 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/puma" +require "capistrano/rails/assets" +require "capistrano/rails/migrations" +require "capistrano/rails/console" +require "capistrano/sidekiq" +install_plugin Capistrano::Sidekiq # Default sidekiq tasks +install_plugin Capistrano::Sidekiq::Systemd # Systemd integration +install_plugin Capistrano::Puma +install_plugin Capistrano::Puma::Systemd + +# 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 c66b498f..09a248f1 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,15 @@ group :development do gem "letter_opener_web" gem "listen", "~> 3.7.1" gem "web-console" + + gem "capistrano" + gem "capistrano3-puma", "~> 6.0" + gem "capistrano-bundler" + gem "capistrano-passenger" + gem "capistrano-rails" + gem "capistrano-rails-console" + gem "capistrano-rbenv" + gem "capistrano-sidekiq" end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 07c6d0a5..816ab683 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,8 @@ GEM activesupport (>= 6.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + airbrussh (1.5.3) + sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) aws-eventstream (1.3.0) aws-partitions (1.972.0) @@ -112,6 +114,32 @@ GEM activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) + capistrano (3.19.2) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (2.1.1) + capistrano (~> 3.1) + capistrano-passenger (0.2.1) + capistrano (~> 3.0) + capistrano-rails (1.7.0) + capistrano (~> 3.1) + capistrano-bundler (>= 1.1, < 3) + capistrano-rails-console (2.3.0) + capistrano (>= 3.5.0, < 4.0.0) + sshkit-interactive (~> 0.3.0) + capistrano-rbenv (2.2.0) + capistrano (~> 3.1) + sshkit (~> 1.3) + capistrano-sidekiq (3.0.0) + capistrano (>= 3.9.0) + capistrano-bundler + sidekiq (>= 6.0.6) + capistrano3-puma (6.0.0) + capistrano (~> 3.7) + capistrano-bundler + puma (>= 5.1, < 7.0) capybara (3.40.0) addressable matrix @@ -559,8 +587,13 @@ GEM net-protocol net-protocol (0.2.2) timeout + net-scp (4.1.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) net-smtp (0.5.1) net-protocol + net-ssh (7.3.0) nio4r (2.7.3) nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) @@ -850,6 +883,15 @@ GEM spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) spring (>= 4) + sshkit (1.24.0) + base64 + logger + net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) + net-ssh (>= 2.8.0) + ostruct + sshkit-interactive (0.3.0) + sshkit (~> 1.12) statsd-ruby (1.5.0) strscan (3.1.2) temple (0.10.3) @@ -924,6 +966,14 @@ DEPENDENCIES aws-sdk-s3 barnes byebug + capistrano + capistrano-bundler + capistrano-passenger + capistrano-rails + capistrano-rails-console + capistrano-rbenv + capistrano-sidekiq + capistrano3-puma (~> 6.0) dalli decidim (= 0.30.0.rc3) decidim-conferences (= 0.30.0.rc3) diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 00000000..dc879982 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +# config valid for current version and patch releases of Capistrano +lock "~> 3.19.2" + +SSHKit.config.command_map[:sidekiq] = 'bundle exec sidekiq' +SSHKit.config.command_map[:sidekiqctl] = 'bundle exec sidekiqctl' + +set :rbenv_type, :user +set :rbenv_ruby, '3.3.4' + +set :application, "metadecidim" +set :repo_url, "https://github.com/decidim/metadecidim.git" + +# Default branch is :master +set :branch, `git rev-parse --abbrev-ref HEAD`.chomp + +# Default deploy_to directory is /var/www/my_app_name +set :deploy_to, "/home/ubuntu/decidim" + +# 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, ".rbenv-vars" + +# Default value for linked_dirs is [] +append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system", "vendor/bundle", "public/uploads", "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 + +set :bundle_path, nil +set :bundle_flags, nil + +Rake::Task['deploy:assets:backup_manifest'].clear_actions +Rake::Task['deploy:assets:restore_manifest'].clear_actions + +namespace :deploy do + desc 'Decidim webpacker configuration' + task :decidim_webpacker_install do + on roles(:all) do + within release_path do + execute :'. ~/.nvm/nvm.sh' + execute 'npm', 'ci' + end + end + end + + before 'deploy:assets:precompile', 'deploy:decidim_webpacker_install' +end diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 00000000..11db23a3 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,60 @@ +# 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} + +server ENV["PRODUCTION_SERVER"], user: ENV["PRODUCTION_USER"], roles: %w{app db web worker} + +# 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 :rails_env, 'production' + +set :ssh_options, { + verify_host_key: :never +} + +# 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" +# }