0
0

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 3 years have passed since last update.

【初学者向け】config/deploy.rb に環境変数を仕込む方法

Posted at

Capistrano + unicorn を用いた自動デプロイで好きな環境変数を
デプロイ先のサーバーにも、githubにも記載なしで送り込む方法です。
basic認証のアカウント名とパスワード設定など、環境変数を使う際にご活用ください。

config/deploy.rb
set :default_env, {
  (デプロイ先での環境変数名): ENV["デプロイ元の端末の環境変数名"],
 例:
 BASIC_AUTH_PASSWORD: ENV["BASIC_AUTH_PASSWORD"]
}

上記の記載をすることで、bundle exec cap production deployをすると
デプロイ端末の環境変数の値がデプロイ先の環境変数の値になります。

同じ環境変数をデプロイ先で設定していた場合、上記の記述の値が優先されますのでご注意ください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?