LoginSignup
4
4

More than 5 years have passed since last update.

LocomotiveCMS で、複数の Heroku インスタンスを使う

Last updated at Posted at 2014-04-09

基本的には Rails アプリケーションなので同じなのですが。

今までのサイトをステージングに変更、新たに本番の環境を追加

git remote rename heroku staging
git remote add production git@yourappproduction.com:fivejcup.git

以前の手順通りに、MongoHQ add-on を追加

heroku addons:add mongohq --remote production

config/mongoid.yml に staging の行を追加

config/mongoid.yml
(省略)
staging:                                                                                               
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>
production:                                                                                               
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>

同様にsendgrid の設定もする

heroku addons:add sendgrid:starter --remote production
cp config/environments/production.rb config/environments/staging.rb

config の設定も変更

heroku config:set RACK_ENV=staging --app staging_app_name #旧環境の設定をstagingに変更
heroku config:set RAILS_ENV=staging --app staging_app_name #旧環境の設定をstagingに変更
heroku config:add BUNDLE_WITHOUT=development:test --app production_app_name #新環境の設定を追加
heroku config:add HEROKU_API_KEY=<YOUR HEROKU API KEY> --app production_app_name #新環境の設定を追加
heroku config:add HEROKU_APP_NAME=<YOUR APP NAME> --app production_app_name #新環境の設定を追加
heroku config:add S3_KEY_ID=<YOUR S3 KEY ID> --app production_app_name #新環境の設定を追加
heroku config:add S3_SECRET_KEY=<YOUR S3 SECRET KEY> --app production_app_name #新環境の設定を追加
heroku config:add S3_BUCKET=<YOUR S3 BUCKET NAME> --app production_app_name #新環境の設定を追加
heroku config:add S3_BUCKET_REGION=<YOUR S3 BUCKET REGION> --app production_app_name #新環境の設定を追加

carrierwave の設定(stagingの追加)

config/initializers/carrierwave.rb
(中略)
  when :staging
    # the following configuration works for Amazon S3
    config.storage          = :fog
    config.fog_credentials  = {
      provider:                 'AWS',
      aws_access_key_id:        ENV['S3_KEY_ID'],
      aws_secret_access_key:    ENV['S3_SECRET_KEY'],
      region:                   ENV['S3_BUCKET_REGION']
    }
    config.fog_directory    = ENV['S3_BUCKET']                                                         

  when :production
    # the following configuration works for Amazon S3
    config.storage          = :fog
    config.fog_credentials  = {
      provider:                 'AWS',
      aws_access_key_id:        ENV['S3_KEY_ID'],
      aws_secret_access_key:    ENV['S3_SECRET_KEY'],
      region:                   ENV['S3_BUCKET_REGION']
    }
    config.fog_directory    = ENV['S3_BUCKET']
..

staging でエラーが出ないかどうか確認しましょう。

git push staging master 

問題なければ、本番にもpushしてみます。

git push production master

無事新しくサイトが作成されればOK


Locomotive 関連の記事一覧:
* Locomotive Engine を Heroku で動かすまで
* LocomotiveCMS でニュース記事一覧機能を作る
* LocomotiveCMS のページにユーザー認証機能を組み込む(Engineの拡張)
* LocomotiveCMS + Devise を使って作ったログインページのデザインをCMS側でできるようにする(1)
* LocomotiveCMS + Devise を使って作ったログインページのデザインをCMS側でできるようにする(2)
* LocomotiveCMS + Devise を使って作ったログインページのデザインをCMS側でできるようにする(3)
* LocomotiveCMS で、複数の Heroku インスタンスを使う

4
4
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
4
4