Production Variables

Im is currently deploying my Rails application on Amazon and Im, encountering a problem with environment variables.

I use the dotenv gem for development and testing, and it works fine trying to access my environment variables, but it doesn't seem to work in production. I read that the Doten gem is not intended for production. I have to set almost 20 different environment variables, including API keys, etc., I am deploying with rubber / capistrano.

How can I make this work in a clean way?

+4
source share
3 answers

You can use figaro gem . I use this and it works great in production.

+1
source

The dotenv-deployment readme mentions how you can use it in a production environment:

If you are using Capistrano 3+:

Just add .env to the list of related files:

set :linked_files, %w{.env} 

If you are using Capistrano 2.xx version:

In your config/deploy.rb :

 require "dotenv/capistrano" 

It symbolizes the .env link located in /path/to/shared in the new version.

Remember to add :production group to the dotenv-rails stone in the Gemfile application:

 gem 'dotenv-rails', :groups => [:development, :test, :production] 
+14
source

In Capistrano 3, add require "dotenv/rails-now" to your Capfile. This will ensure that capistrano also has access to the environment.

(We had problems with capistrano using the API token for applignal, so capistrano was unable to notify applicationignal when a new deployment was completed)

0
source

Source: https://habr.com/ru/post/1486646/


All Articles