以前といっても既に、3年程前に、Capstranoを設定していたが、既にCapstrano3.xの時代。
久しぶりに設定する機会があったので覚え書き。
Railsの設定
Gemfile にデフォルトでコメントアウトされている下記の記述を有効にして、bundle update 。
[ruby]
# Use Capistrano for deployment
gem ‘capistrano-rails’, group: :development
[/ruby]
[bash]
$ bundle update
[/bash]
[bash]
$ capify .
——————————————————————————–
Capistrano 3.x is incompatible with Capistrano 2.x.
This command has become `cap install` in Capistrano 3.x
For more information see http://www.capistranorb.com/
——————————————————————————–
[/bash]
capify . にて設定ファイルを作成しようとしたが、怒られたので、cap install を実行する。
[bash]
$ 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
create Capfile
Capified
[/bash]
すると、Capfile と、config/deploy.rb、config/deploy/staging.rb、config/deploy/production.rb が作成される。
Gitのサーバ設定
Gitのインストール。
[bash]
$ yum install git
[/bash]
Git共有リポジトリの作成。
[bash]
$ mkdir /var/lib/git/public_git/sample.git
$ cd /var/lib/git/public_git/sample.git
$ git init –bare –share
[/bash]
Gitのクライアント設定
[bash]
$ git init
$ git add .
$ git commit -m "First commit"
$ git remote add sample ssh://User名@Host名:SSHポート番号/var/lib/git/public_git/sample.git
$ git push sample
[/bash]