Skip to content

Instantly share code, notes, and snippets.

@damuz91
Last active April 15, 2022 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damuz91/99b5c10ecc74b3e4dcdc50b1944159a9 to your computer and use it in GitHub Desktop.
Save damuz91/99b5c10ecc74b3e4dcdc50b1944159a9 to your computer and use it in GitHub Desktop.
My mina production deployment script for AL2
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
set :application_name, 'railsapp'
set :domain, '255.255.255.255'
set :deploy_to, '/home/ec2-user/production/railsapp'
set :repository, 'git@github.com:company/railsapp.git'
set :branch, 'main'
set :user, 'ec2-user'
set :forward_agent, true
set :rvm_use_path, '/usr/share/rvm/bin/rvm'
set :shared_files, fetch(:shared_files, []).push('.env.production')
task :remote_environment do
invoke :'rvm:use', 'ruby-2.7.0'
end
desc "Deploys the current version to the server."
task :deploy do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
on :launch do
in_path(fetch(:current_path)) do
command %{mkdir -p tmp/}
command %{touch tmp/restart.txt}
command %{sudo service puma restart}
command %{sudo service sidekiq restart}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment