Tag: Capistrano3
以下bundle経由で使用する方法を説明する。
group :deployment do gem 'capistrano' gem 'capistrano-rails' gem 'capistrano-rbenv' gem 'capistrano-bundler' end
bundle install --path vendor/bundle
$ cd myproject $ cap install mkdir -p config/deploy create config/deploy.rb create config/deploy/staging.rb create config/deploy/production.rb mkdir -p lib/capistrano/tasks Capified
# Load DSL and Setup Up Stages require 'capistrano/setup' # Includes default deployment tasks require 'capistrano/deploy' # Includes 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 # # require 'capistrano/rvm' require 'capistrano/rbenv' # require 'capistrano/chruby' require 'capistrano/bundler' require 'capistrano/rails/assets' #require 'capistrano/rails/migrations' # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
group :deployment do gem 'capistrano', '~> 3.0', require: false gem 'rubyzip', require: false end
require 'zip' Zip.setup do |c| c.unicode_names = true c.on_exists_proc = true c.continue_on_exists_proc = true end namespace :copy do task :check do end task :set_current_revision do end task create_release: 'release.zip' do |t| file = t.prerequisites.first on roles(:app) do execute :mkdir, '-p', fetch(:tmp_dir) upload! file, fetch(:tmp_dir) execute :unzip, '-o', "#{fetch(:tmp_dir)}/release.zip", '-d', release_path end File.delete file if File.exists?(file) end file 'release.zip' do |t| release_filename = File.join(Dir.pwd, t.name) Dir.chdir fetch(:copy_dir) do Zip::File.open(release_filename, Zip::File::CREATE) do |zipfile| files = FileList['**/*'] files.exclude(*fetch(:copy_exclude)).each do |file| zipfile.add(file, file) end end end end end
set :scm, 'copy' set :copy_dir, '.' set :tmp_dir, '/tmp' set :copy_exclude, [ /\.log$/, %r!^files/.+! ]
set :copy_exclude, [ /^logs/, /^tmp/, /^vendor/ ]
role :app, %w{deploy@example.com} role :web, %w{deploy@example.com} role :db, %w{deploy@example.com} # 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 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value