14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RailsアプリケーションをCircleCI, Capistranoで自動デプロイ

Last updated at Posted at 2015-07-27

Capistranoの設定

参考サイト
http://chroju89.hatenablog.jp/entry/2014/02/20/000348

  1. Railsアプリケーションの作成
    RubyMineでRailsアプリケーションを新規作成。
    この時点でリポジトリ登録しといた。

  2. Gemfile にcapistrano系を追加
    ※deploy先がrvmの場合、capistrano-rvmを入れる。

Gemfile
group :development do
    gem 'capistrano', '~> 3.1.0'
    gem 'capistrano-rails', '~> 1.0.0'
    gem 'capistrano-bundler', '~> 1.1.2'
    gem 'capistrano-rvm'
end
  1. bundle install

  2. bundle exec cap install

  3. Capfileの編集
    require 'capistrano/deploy' の下に追加

Capfile
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
  1. config/deploy.rbの編集
    以下を編集、追記
config/deploy.rb
set :application, 'rails-cap'
set :repo_url, 'git@github.com:nomuson/rails-cap.git'
set :deploy_to, '/var/www/rails-cap'
set :scm, :git
  1. config/deploy/ 配下の設定ファイルを編集

  2. 実行

bundle exec cap production deploy

CircleCIの設定

参考サイト
http://qiita.com/ysk_1031/items/f584a0599791bdba132a

  1. リポジトリを選択

  2. アプリケーションにcircle.ymlを作成

  3. deploy用のshファイルを作成

  4. IAMユーザーの作成

  1. CircleCIにIAMユーザーのCredentialsを設定
    Project Settings -> [Permissions] AWS Permissions

  2. CircleCIに対象サーバの秘密鍵を設定
    Project Settings -> [Permissions] SSH Permissions

※ 1Containerまで無料。2Containerから$50ずつ月額課金。

14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?