Skip to content

Instantly share code, notes, and snippets.

@getjump
Forked from forsaken1/Capfile
Created October 22, 2015 23:31
Show Gist options
  • Save getjump/6c222142f714876055f4 to your computer and use it in GitHub Desktop.
Save getjump/6c222142f714876055f4 to your computer and use it in GitHub Desktop.
Capistrano 3 deploy with Unicorn and Nginx
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/unicorn_nginx'
require 'rvm1/capistrano3'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
# config valid only for current version of Capistrano
lock '3.3.5'
set :application, 'coupon_generator'
set :repo_url, 'git@yourrepourl'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/secrets.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/assets')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
end
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
role :app, %w{[email protected]}
role :web, %w{[email protected]}
role :db, %w{[email protected]}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server definition into the
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.
server 'server.com', user: 'user', roles: %w{web app}
set :nginx_server_name, 'server.com'
set :rvm1_ruby_version, "#{fetch(:ruby_version)}@#{fetch(:application)}"
set :user, 'user'
set :branch, 'master'
set :stage, 'production'
set :rails_env, 'production'
set :deploy_to, '/path/to/project/dir'
set :ssh_options, {
forward_agent: true
}
group :development do
gem 'capistrano', '3.3.5'
gem 'capistrano-rails', '1.1.2'
gem 'rvm1-capistrano3', require: false
gem 'capistrano-unicorn-nginx', '3.3.2'
end
group :production do
gem 'unicorn', '4.8.3'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment