minaを使って以下なコンセプトなデプロイをちゃらっとやりたかった。だけど、githubのプライベートリポジトリからのデプロイをしようとすると結構大変っぽかったのね(capistranoでの「set deploy_via, :copy」的な事が簡単にできなかった、、、)。なんで、今更感が漂いまくりだけどcapistranoでやってみた。ついでに「今更」なんだけどdeploy.rbもさらしてみる!!!!(貧乏備忘記事だよ!)
コンセプト
releasesフォルダの運用と、最新リリースへのcurrent名でのシンボリックリンクの作成だけやりたいんや!!!
config/deploy.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # # most simple deploying sample. # # only needs releases folder and symlinking to current. # case you want to deploy static html files to nginx # # with capistrano (2.14.2) # set :application, "your_server.example.com" set :deploy_to, "/path/to/deploy" set :use_sudo, false set :scm, :git set :repository, "your repository" set :branch, :master set :git_shallow_clone, 1 # comment below if your repository is public set :deploy_via, :copy set :copy_exclude, [".git", ".DS_Store"] # linux tar hates OSX tar # to install gnu-tar by homebrew 'brew install gnu-tar' set :copy_local_tar, "gnutar" if `uname` =~ /Darwin/ role :web, "server1" # I'm using .ssh/config file #set :user, "user_for_server1" # I'm using IdentityFile #set :scm_username, "user_for_git" # what a coward I am set :keep_releases, 6 # skipping shared symlinking set :shared_children, %w() # customizing deploy tasks namespace :deploy do # do not need a shared folder task :setup do run "mkdir -p #{deploy_to}/releases" end task :default do transaction do update_code symlink end end task :update_code, :except => { :no_release => true } do on_rollback { run "rm -rf #{release_path}; true" } strategy.deploy! end after "deploy", "deploy:cleanup" end |