Skip to content

Instantly share code, notes, and snippets.

@kirqe
Last active December 20, 2017 13:15
Show Gist options
  • Save kirqe/efbac95f70f0f3837e86 to your computer and use it in GitHub Desktop.
Save kirqe/efbac95f70f0f3837e86 to your computer and use it in GitHub Desktop.
Mina deploy.rb example
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
set :domain, 'domain.com'
set :deploy_to, '/var/www/app_name'
set :repository, 'git@github.com:username/repo_name.git'
set :branch, 'master'
# For system-wide RVM install.
#set :rvm_path, '/usr/local/rvm/bin/rvm'
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log', 'config/application.yml']
# Optional settings:
set :user, 'ssh_username' # Username in the server to SSH to.
set :port, '22' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
# invoke :'rbenv:load'
queue 'source ~/.bash_profile'
# For those using RVM, use this to load an RVM version@gemset.
invoke :'rvm:use[ruby-2.2.2]'
end
# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment