# config/deploy.rb# lock Capistrano Versionlock'3.6.1'# application nameset:application,'my_app_name'# which repo to pull from when deployingset:repo_url,'git@example.com:me/my_repo.git'# ask which brnach to pull from when deploying# Default branch is :masterask:branch,`git rev-parse --abbrev-ref HEAD`.chomp# location to put your app on server# Default deploy_to directory is /var/www/my_app_nameset:deploy_to,'/home/deploy/my_app_name'# rbenv settings, version and pathset:rbenv_ruby,'2.2.3'# these files will be symlinked to APP_PATH/shared/# Default value for :linked_files is []set:linked_files,%w(config/database.yml config/secrets.yml)# these directories will be symlinked to APP_PATH/shared/# Default value for linked_dirs is []set:linked_dirs,%w(log tmp/pids tmp/cache tmp/sockets public/system)# setting $PATH# Default value for default_env is {}set:default_env,{path:"/opt/ruby/bin:$PATH"}# how many releases you want to keep on serverset:keep_releases,3# 也可以在這裡設定一些 hook# 範例namespace:deploydodesc"Run custom task"after:published,:taskdo# 在什麼 flow 之後onrelease_roles:alldo# 可以執行的主機權限within"#{current_path}"do# 在 current 目錄底下withrails_env::stagingdo# 在 staging 環境execute:rake,"task_run"endendendendend
1234
# config/deploy/production.rb# 用來設定連哪台 server, user 是誰, 該主機有什麼權限# db: 處理 db 相關,像是跑 migrate, web: 跑 asset:precompileserver'example.com',user:'deploy',roles:%w{app db web},my_property::my_value
Capfile 設定檔
require 需要的檔案
1234567891011121314151617181920212223242526272829
# Capfile# Load DSL and set up stagesrequire"capistrano/setup"# Include default deployment tasksrequire"capistrano/deploy"# Include tasks from other gems included in your Gemfile## For documentation on these, see for example:## https://github.com/capistrano/rvm# https://github.com/capistrano/rbenv# https://github.com/capistrano/chruby# https://github.com/capistrano/bundler# https://github.com/capistrano/rails# https://github.com/capistrano/passenger## require 'capistrano/rvm'# require 'capistrano/rbenv'# require 'capistrano/chruby'# require 'capistrano/bundler'# require 'capistrano/rails/assets'# require 'capistrano/rails/migrations'# require 'capistrano/passenger'# Load custom tasks from `lib/capistrano/tasks` if you have any definedDir.glob("lib/capistrano/tasks/*.rake").each{|r|importr}