LoginSignup
11
11

More than 5 years have passed since last update.

Herokuのforkコマンドで簡単に既存の本番環境からステージング環境を作る。

Posted at

参考

heroku fork コマンドで作成

$ heroku fork -a hoge hoge-staging

で アプリケーションhogeがhoge-stagingにコピーされます。

heroku info で git remoteの情報を取得、追加

heroku fork コマンドでは自動でgit remote は追加されないので自分で行います。

$ heroku info -a hoge-staging

で表示される GIt URL の部分を追加

$ git remote add staging git@heroku.com:hoge-staging.git

これで

$ git push staging master

でステージング環境にpushすることができる。

Staging用にRACK_ENVとRAILS_ENVを設定

$ heroku config:set RACK_ENV=staging RAILS_ENV=staging --remote staging

これでステージングのログ見るときとか、ステージングに反映させたい環境変数とか設定するときは

bash
$ heroku logs -t --remote staging

既存のやつをみたいときは

bash
$ heroku logs -t --remote heroku

で出来たりする

ステージング環境設定を本番と同じにする

シンボリックリンクをはる。

$ ln -s config/environments/production.rb config/environments/staging.rb

heroku forkでつくったアプリケーションの削除

$ heroku  destroy -a hoge-staging

で削除することが可能。

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