From 1c0a3c388591250c4434fffdccf39a958ce472be Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Mon, 7 Jul 2025 15:33:02 +0200 Subject: [PATCH 1/3] change deployment configs for migrating to inrae servers --- config/deploy.rb | 49 ++++++++----------- .../deploy/{agroportal.rb => production.rb} | 6 +-- config/deploy/staging.rb | 4 +- config/deploy/test.rb | 4 +- 4 files changed, 27 insertions(+), 36 deletions(-) rename config/deploy/{agroportal.rb => production.rb} (75%) diff --git a/config/deploy.rb b/config/deploy.rb index 6916caf54..8a14c1e23 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -8,7 +8,7 @@ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } # Default deploy_to directory is /var/www/my_app -set :deploy_to, "/srv/ontoportal/#{fetch(:application)}" +set :deploy_to, "/opt/ontoportal/#{fetch(:application)}" # Default value for :scm is :git # set :scm, :git @@ -23,14 +23,16 @@ # set :pty, true # Default value for :linked_files is [] -# set :linked_files, %w{config/database.yml} +append :linked_files, 'config/unicorn.rb', 'config/environments/appliance.rb', 'config/environments/site_config.rb' # Default value for linked_dirs is [] # set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} set :linked_dirs, %w{log vendor/bundle tmp/pids tmp/sockets public/system} # Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } +set :default_env, { + 'PATH' => "/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/bin:$PATH" +} # Default value for keep_releases is 5 set :keep_releases, 5 @@ -38,31 +40,20 @@ # If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb: -SSH_JUMPHOST = ENV.include?('SSH_JUMPHOST') ? ENV['SSH_JUMPHOST'] : 'jumpbox.hostname.com' -SSH_JUMPHOST_USER = ENV.include?('SSH_JUMPHOST_USER') ? ENV['SSH_JUMPHOST_USER'] : 'username' +# SSH_JUMPHOST = ENV.include?('SSH_JUMPHOST') ? ENV['SSH_JUMPHOST'] : 'jumpbox.hostname.com' +# SSH_JUMPHOST_USER = ENV.include?('SSH_JUMPHOST_USER') ? ENV['SSH_JUMPHOST_USER'] : 'username' +# JUMPBOX_PROXY = "#{SSH_JUMPHOST_USER}@#{SSH_JUMPHOST}" -JUMPBOX_PROXY = "#{SSH_JUMPHOST_USER}@#{SSH_JUMPHOST}" set :ssh_options, { user: 'ontoportal', - forward_agent: 'true', - keys: %w(config/deploy_id_rsa), - auth_methods: %w(publickey), - # use ssh proxy if API servers are on a private network - proxy: Net::SSH::Proxy::Command.new("ssh #{JUMPBOX_PROXY} -W %h:%p") + # forward_agent: 'true', + # keys: %w(config/deploy_id_rsa), + # auth_methods: %w(publickey), + # proxy: Net::SSH::Proxy::Command.new("ssh #{JUMPBOX_PROXY} -W %h:%p") } # private git repo for configuraiton -PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://your_github_pat_token@github.com/your_organization/ontoportal-configs.git' -desc "Check if agent forwarding is working" -task :forwarding do - on roles(:all) do |h| - if test("env | grep SSH_AUTH_SOCK") - info "Agent forwarding is up to #{h}" - else - error "Agent forwarding is NOT up to #{h}" - end - end -end +# PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://your_github_pat_token@github.com/your_organization/ontoportal-configs.git' # inspired by http://nathaniel.talbott.ws/blog/2013/03/14/post-deploy-smoke-tests/ desc 'Run smoke test' @@ -115,20 +106,20 @@ on roles(:app), in: :sequence, wait: 5 do # Your restart mechanism here, for example: # execute :touch, release_path.join('tmp/restart.txt') - execute 'sudo systemctl restart unicorn' + execute 'sudo systemctl restart unicorn.service' execute 'sleep 5' end end after :updating, :get_config after :publishing, :restart + after :restart, :clear_cache - after :restart, :clear_cache do - on roles(:web), in: :groups, limit: 3, wait: 10 do - # Here we can do anything such as: - # within release_path do - # execute :rake, 'cache:clear' - # end + desc 'Clear the cache' + task :clear_cache do + on roles(:app), in: :sequence, wait: 5 do + execute 'sudo opclearcaches' end end + end diff --git a/config/deploy/agroportal.rb b/config/deploy/production.rb similarity index 75% rename from config/deploy/agroportal.rb rename to config/deploy/production.rb index c01f3fb90..ad91ad80e 100644 --- a/config/deploy/agroportal.rb +++ b/config/deploy/production.rb @@ -4,9 +4,9 @@ # 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[agroportal.lirmm.fr] -role :db, %w[agroportal.lirmm.fr] # sufficient to run db:migrate only on one system -set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'master' +role :app, %w[agroportal.eu] +role :db, %w[agroportal.eu] # sufficient to run db:migrate only on one system +set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'agroportal-new-deployment-configs' # Extended Server Syntax # ====================== # This can be used to drop a more detailed server diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 47b158aec..d19ca6d7c 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -4,8 +4,8 @@ # 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{stageportal.lirmm.fr} -role :db, %w{stageportal.lirmm.fr} # sufficient to run db:migrate only on one system +role :app, %w{stage.agroportal.eu} +role :db, %w{stage.agroportal.eu} # sufficient to run db:migrate only on one system set :branch, ENV.include?('BRANCH') ? ENV['BRANCH'] : 'stage' # Extended Server Syntax # ====================== diff --git a/config/deploy/test.rb b/config/deploy/test.rb index fcbe1efce..7c07d3d01 100644 --- a/config/deploy/test.rb +++ b/config/deploy/test.rb @@ -4,8 +4,8 @@ # 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{testportal.lirmm.fr} -role :db, %w{testportal.lirmm.fr} # sufficient to run db:migrate only on one system +role :app, %w{test.agroportal.eu} +role :db, %w{test.agroportal.eu} # sufficient to run db:migrate only on one system # Extended Server Syntax # ====================== # This can be used to drop a more detailed server From 46aa19d07656ebc9288745a0396422ed87d9738e Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Mon, 7 Jul 2025 15:36:03 +0200 Subject: [PATCH 2/3] add bundle flags to remove --quite --- config/deploy.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/deploy.rb b/config/deploy.rb index 8a14c1e23..980851973 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -38,6 +38,9 @@ set :keep_releases, 5 set :config_folder_path, "#{fetch(:application)}/#{fetch(:stage)}" +# set bundle options +set :bundle_flags, "" + # If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb: # SSH_JUMPHOST = ENV.include?('SSH_JUMPHOST') ? ENV['SSH_JUMPHOST'] : 'jumpbox.hostname.com' From b79058235d4ab3059d9a217cd5664dcc08184f3e Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Mon, 7 Jul 2025 15:42:36 +0200 Subject: [PATCH 3/3] add bundle flags to add verbose --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 980851973..70e3b58bc 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -39,7 +39,7 @@ set :config_folder_path, "#{fetch(:application)}/#{fetch(:stage)}" # set bundle options -set :bundle_flags, "" +set :bundle_flags, "--verbose" # If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb: