I’m trying to setup capistrano since yesterday. Unfortunately I couldn’t find a single article which could guide me with whole process except this one.
Though setting up capistrano is quite easy, I was stuck at securing database.yml from committing to repository. I wanted to keep it on server side for security purpose. There were several answers on stackoverflow to use `ln -s ..`.
I also stumbled upon an image, which describes the capistrano deployment flow, which is worth mentioning.
The essential key point I was missing here is, capistrano already provided `linked_files` variable, which will automatically create a softlink from shared directory.
To understand it more clearly, when we deploy with capistrano, it creates three directory inside your ‘app’ folder:
deployer@localhost:/var/www/your_own_store$ ls
releases repo shared
releases: It has different release version of your app. One release is created with one deployment.
repo: It has the actual repository cloned.
shared: It has the shared files/dir, which usually doesn’t changes with each deployment. e.g. database.yml/assets etc
So, to create a softlink just add following line to your deploy.rb file:
..
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml} # <------
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
..
This will automatically create a softlink for your database.yml.
The point not to be missed here is: You’ll have to manually put this database.yml on your server.