Created
April 29, 2015 04:36
-
-
Save forsaken1/4d0b0ecdd12a34ad056e to your computer and use it in GitHub Desktop.
Capistrano 3 deploy with Unicorn and Nginx
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
# 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 } |
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
# 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 |
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
# 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 | |
} |
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
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