7

I have two config-files

/app/config/database.yml

and

/app/config/userconfig.yml

i don't want to put the database credentials and userconfig in the svn-repository, so i have database.yml.dist and userconfig.yml.dist checked in.

What is the best way to get copys of the dist-files in the shared-directory when deploying the app for the first time?

For later deploys i'll link to them from /app/current/config

Zoran Zaric
  • 1,211
  • 2
  • 11
  • 19

2 Answers2

11

You should place your config files in

/path/to/deployed_app/shared

Then in a capistrano task, sym link to those files:

namespace :deploy do
  task :symlink_shared do
    run "ln -s #{shared_path}/database.yml #{release_path}/config/"
  end
end

before "deploy:restart", "deploy:symlink_shared"
erik
  • 6,406
  • 3
  • 36
  • 36
1

In Capistrano v3, you can use a task called deploy:symlink:shared.

Provide a list of files you placed in the shared directory, so Capistrano knows which files to symlink when the task is run. This is typically done in deploy.rb:

set :linked_files, %w{
  app/config/database.yml
  app/config/userconfig.yml
}

Related: Capistrano - How to put files in the shared folder?

Community
  • 1
  • 1
Andrew
  • 2,770
  • 1
  • 22
  • 29
  • Capistrano doesn't provide a way to upload these files from your local tree though, you'll have to do this manually (through SSH typically) or use a custom task as explained here: http://stackoverflow.com/a/23520809/814224 – xuuso May 07 '14 at 14:39