From 4e43aafe32dc0fa80e615a48067e714ce95688aa Mon Sep 17 00:00:00 2001 From: aaccensi Date: Thu, 15 Oct 2026 15:58:54 +0200 Subject: [PATCH] Cleanup Capistrano deploy config Deploys have been done with Docker and deploy.sh for a long time (capistrano gem was dropped from the Gemfile in 667919202), so these files have been unused since then. Also drops some Rubocop Layout/LineLength excludes that no longer point at anything with the files gone. --- .rubocop.yml | 4 -- config/deploy.rb | 94 ------------------------------ config/deploy/production.rb | 50 ---------------- config/deploy/staging.rb | 50 ---------------- lib/capistrano/tasks/database.rake | 45 -------------- 5 files changed, 243 deletions(-) delete mode 100644 config/deploy.rb delete mode 100644 config/deploy/production.rb delete mode 100644 config/deploy/staging.rb delete mode 100644 lib/capistrano/tasks/database.rake diff --git a/.rubocop.yml b/.rubocop.yml index a1b5377f00..60a65da067 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -85,10 +85,6 @@ Layout/FirstHashElementIndentation: # little limiting when there are multiple nested modules. We compromise at 100. Layout/LineLength: Max: 100 - # Ignore long comments in deploy configs. - Exclude: - - config/deploy.rb - - config/deploy/*.rb IgnoredPatterns: - '(context|context|it|shared_examples_for)' diff --git a/config/deploy.rb b/config/deploy.rb deleted file mode 100644 index 14f74000d2..0000000000 --- a/config/deploy.rb +++ /dev/null @@ -1,94 +0,0 @@ -lock '3.16.0' - -set :log_level, 'info' - -set :application, 'etmodel' -set :repo_url, 'https://github.com/quintel/etmodel.git' - -# Set up rbenv -set :rbenv_type, :user -set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" -set :rbenv_map_bins, %w{rake gem bundle ruby rails} - -set :bundle_binstubs, (-> { shared_path.join('sbin') }) - -# Default branch is :master -# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call - -# Default deploy_to directory is /var/www/my_app -# set :deploy_to, "/var/www/#{fetch(:application)}" - -# Default value for :scm is :git -# set :scm, :git - -# Default value for :format is :pretty -# set :format, :pretty - -# Default value for :log_level is :debug -# set :log_level, :debug - -# Default value for :pty is false -# set :pty, true - -# Default value for :linked_files is [] -set :linked_files, - %w{config/database.yml config/config.yml config/email.yml config/secrets.yml config/settings.local.yml} - -# Default value for linked_dirs is [] -set :linked_dirs, - %w{sbin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} - -# Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } - -# Default value for keep_releases is 5 -# set :keep_releases, 5 - -namespace :deploy do - after :publishing, :restart - - # The cache lives in Solid Cache (database-backed), so it survives restarts - # and deploys unless cleared explicitly. Stale entries otherwise keep serving - # outdated responses (see quintel/multi-year-charts#123). - after :restart, :clear_cache do - on roles(:app) do - within current_path do - with rails_env: fetch(:rails_env, fetch(:stage)) do - execute :bundle, :exec, :rails, :runner, "'Rails.cache.clear'" - end - end - end - end -end - -# Puma Options -# ============ -# If these are changed, be sure to then run `cap $stage puma:config`; the config -# on the server is not automatically updated when deploying. - -set :puma_threads, [1, 1] -set :puma_workers, 4 -set :puma_init_active_record, true -set :puma_preload_app, true - -# Capistrano Maintenance -# ====================== - -set :maintenance_template_path, - File.expand_path('../../public/maintenance.html', __FILE__) - -# Webpacker -# ========= - -before 'deploy:assets:precompile', 'deploy:yarn_install' - -namespace :deploy do - desc 'Run rake yarn:install' - task :yarn_install do - on roles(:web) do - within release_path do - execute("cd #{release_path} && yarn install") - end - end - end -end diff --git a/config/deploy/production.rb b/config/deploy/production.rb deleted file mode 100644 index 3418405b9c..0000000000 --- a/config/deploy/production.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Simple Role Syntax -# ================== -# Supports bulk-adding hosts to roles, the primary server in each group -# is considered to be the first unless any hosts have the primary -# property set. Don't declare `role :all`, it's a meta role. - -# role :app, %w{deploy@example.com} -# role :web, %w{deploy@example.com} -# role :db, %w{deploy@example.com} - - -# Extended Server Syntax -# ====================== -# This can be used to drop a more detailed server definition into the -# server list. The second argument is a, or duck-types, Hash and is -# used to set extended properties on the server. - -server 'et-model.com', - user: 'deploy', - roles: %w[web app db], - ssh_options: { keys: %w[~/.ssh/id_deploy] } - -set :branch, 'production' - - -# Custom SSH Options -# ================== -# You may pass any option but keep in mind that net/ssh understands a -# limited set of options, consult[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/rlisowski/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(password) -# } -# -# And/or per server (overrides global) -# ------------------------------------ -# 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 deleted file mode 100644 index 9ef8e36206..0000000000 --- a/config/deploy/staging.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Simple Role Syntax -# ================== -# Supports bulk-adding hosts to roles, the primary server in each group -# is considered to be the first unless any hosts have the primary -# property set. Don't declare `role :all`, it's a meta role. - -# role :app, %w{deploy@example.com} -# role :web, %w{deploy@example.com} -# role :db, %w{deploy@example.com} - - -# Extended Server Syntax -# ====================== -# This can be used to drop a more detailed server definition into the -# server list. The second argument is a, or duck-types, Hash and is -# used to set extended properties on the server. - -server 'beta.et-model.com', - user: 'deploy', - roles: %w[web app db], - ssh_options: { keys: %w[~/.ssh/id_deploy] } - -set :branch, 'master' - - -# Custom SSH Options -# ================== -# You may pass any option but keep in mind that net/ssh understands a -# limited set of options, consult[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/rlisowski/.ssh/id_rsa), -# forward_agent: false, -# auth_methods: %w(password) -# } -# -# And/or per server (overrides global) -# ------------------------------------ -# 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/lib/capistrano/tasks/database.rake b/lib/capistrano/tasks/database.rake deleted file mode 100644 index 110f72c4a8..0000000000 --- a/lib/capistrano/tasks/database.rake +++ /dev/null @@ -1,45 +0,0 @@ -def system_v(cmd) - info "Execute '#{cmd}'" - system cmd -end - -desc 'Copy database from the server to your local database' -task db2local: ['deploy:set_rails_env'] do - on roles(:app) do - within current_path do - filename = nil - - info 'Creating DB export' - - with rails_env: fetch(:rails_env) do - filename = capture(:rake, 'db:dump_sql').strip - end - - download!(current_path.join(filename), filename) - execute(:rm, current_path.join(filename)) - - local_conf = YAML.load_file('config/database.yml')['development'] - - username = local_conf['username'] - password = local_conf['password'] - database = local_conf['database'] - - credentials = [ - "--user=#{ username }", - password && "--password=#{ password }" - ].compact.join(' ') - - info 'Importing database' - - system_v "gunzip -f #{ filename }" - - system_v "mysqladmin -f #{ credentials } drop #{ database }" - system_v "mysqladmin #{ credentials } create #{ database }" - system_v "mysql #{ credentials } #{ database } < #{ filename.chomp('.gz') }" - - system_v "rm #{ filename.chomp('.gz') }" - - info 'Finished importing database' - end - end -end