I am collaborating with another developer on an app. It is a ruby on rails app using capistrano to deploy to an amazon AWS EC2 instance. I am developing on a local machine and am able to run the command bundle exec production deploy. This works properly and updates the code base and deploys properly.
My partner developer is using gitpod to develop and needs to be able to deploy as well. I have attempted to deploy from gitpod but am experiencing issues.
I am using Capistrano 3.17.3, sshkit 1.21.5, ruby 2.7.3, and rails 6.0.6
I believe configuration is largely completed, the master.key is copied over from my local machine, the linked dir and such are all identical to when I deploy on my local machine. However, when I attempt to deploy from my collaborators gitpod, I encounter the following error:
Caused by:
Errno::ETIMEDOUT: Connection timed out - connect(2) for 3.218.XXX.XXX:22
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:64:in `connect'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:64:in `connect_internal'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:137:in `connect'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:642:in `block in tcp'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:227:in `each'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:227:in `foreach'
/home/gitpod/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/socket.rb:632:in `tcp'
/workspace/tourme_mvp/vendor/bundle/ruby/2.7.0/gems/net-ssh-7.2.0/lib/net/ssh/transport/session.rb:72:in `initialize'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/net-ssh-7.2.0/lib/net/ssh.rb:256:in `new'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/net-ssh-7.2.0/lib/net/ssh.rb:256:in `start'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/connection_pool.rb:63:in `call'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/connection_pool.rb:63:in `with'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/netssh.rb:177:in `with_ssh'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/netssh.rb:130:in `execute_command'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:148:in `tap'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:61:in `test'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/capistrano-rbenv-2.2.0/lib/capistrano/tasks/rbenv.rake:10:in `block (3 levels) in <top (required)>'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:31:in `run'
/workspace/app_name/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.5/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rbenv:validate
It is notable that the server and my local machine are configured to use Rbenv while the gitpod is using rvm. I don't think this is the primary issue because the issue is the ssh connection.
The following is my config/deploy.rb:
require 'capistrano-db-tasks'
set :application, 'app_name'
set :repo_url, 'repo_url'
set :deploy_to, '/home/deploy/app_name'
set :branch, ENV['BRANCH'] if ENV['BRANCH']
set :linked_files, %w{config/database.yml config/master.key}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :keep_releases, 3
set :keep_assets, 3
set :db_local_clean, true
set :db_remote_clean, true
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
And the following is my config/deploy/production.rb:
server '3.218.XXX.XXX', user: 'deploy', roles: %w{web app db}
server '34.238.XXX.XXX', user: 'deploy', roles: %w{web app db}
set :rails_env, 'production'
where the server ip addresses are the AWS EC2 public ips. There are two instances
I followed this youtube video to initially set up my ec2 instances: https://www.youtube.com/watch?v=YJzYmhxB8rE
Again, the linked files are configured properly. Is there something I am missing? Is capistrano deployment from gitpod unreasonable? Is there some method capistrano is using to SSH that I am missing? Although there may be other errors, it appears that none of them can yet be encountered because Capistrano can't SSH into the EC2 instances.