Skip to content

Instantly share code, notes, and snippets.

@davidhq
Created October 31, 2014 23:57
Show Gist options
  • Save davidhq/fe0decad29bb005e9a6d to your computer and use it in GitHub Desktop.
Save davidhq/fe0decad29bb005e9a6d to your computer and use it in GitHub Desktop.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/puma'
require "mina/rsync"
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
set :user, 'david'
set :domain, 'server.bitcells.com'
set :deploy_to, '/var/www/meetcasts'
set :bundle_options, '--without development:test' # this overrides the default options which is to install into vendor/bundle
# 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', '.env', '.ruby-version', 'tmp', 'log']
set :rsync_options, %w[
--recursive --delete --delete-excluded
--exclude .git*
--exclude /config/database.yml
--exclude /test/***
]
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# 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 .rbenv-version to your repository.
invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
# invoke :'rvm:use[ruby-1.9.3-p125@default]'
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/log"]
queue! %[chmod g+rwx,u+rwx,o+rwx "#{deploy_to}/shared/log"]
queue! %[mkdir -p "#{deploy_to}/shared/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/sockets")
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/sockets")
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/pids")
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/pids")
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke "rsync:deploy"
# invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install' #if ENV['BUNDLE']
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
to :launch do
invoke :'puma:phased_restart'
end
invoke :'deploy:cleanup'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment