Last active
April 15, 2022 21:24
-
-
Save damuz91/99b5c10ecc74b3e4dcdc50b1944159a9 to your computer and use it in GitHub Desktop.
My mina production deployment script for AL2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, '[email protected]: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