Reputation: 13862
Having a really hard time getting this to work. I just added dotenv gem to accommodate for the Rails 4.1 secrets.yml file. I also have in the .env
file the database.yml's password.
To add to my deploy:
set :linked_files, %w{config/database.yml .env}
When I run cap production deploy
I get:
/shared/config/database.yml does not exist on 107.170.....
How can I get the database.yml to be added?
I looked at the capistrano touch gem with no luck because after I create the empty files, ActiveRecord throws an error of No 'production' database
Upvotes: 3
Views: 2875
Reputation: 44370
Create task for upload your .env
and database.yml
.Look example below:
desc "Database config"
task :setup_config, roles: :app do
# upload you database.yml from config dir to shared dir on server
put File.read("config/database.yml"), "#{shared_path}/config/database.yml"
# make symlink
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
# upload you database.yml from config dir to shared dir on server
put File.read(".env"), "#{shared_path}/config/.env"
# make symlink
run "ln -nfs #{shared_path}/config/.env #{current_path}/.env"
end
And add before
and after
hooks.
Or use dotenv-deployment
that contain the same tasks.
Upvotes: 2