Capistrano for deployment - moralesalberto/personal GitHub Wiki

The next step is to get this app running on my server using Capistrano.

Install Capistrano

In your Gemfile:

group :development do
  gem 'capistrano'
end

Then bundle install

Then go to your app directory and $ capify . That will create the Capfile and the config/deploy.rb files. Edit the Capfile. For me, I have setup the ssh keys with my server, so no need for passwords. My config/deploy.rb file looks like this:

 require "bundler/capistrano"

set :application, "personal"
set :repository,  "[email protected]:moralesalberto/personal.git"
set :deploy_to, "/u/apps/personal"

set :scm, :git
set :branch, :master
set :use_sudo, false

set :user, "deploy"

set :rails_env, 'production'

set :deploy_via, :copy

set :keep_releases, 5

default_run_options[:pty] = true

after "deploy:update_code", "deploy:migrate"

server "amorales.us", :app, :web, :db, :primary => true

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

Go to the server and create the path /u/apps/[app_name] if it does not exist, create the mysql database, and you should be all set.

Then do a cap deploy:setup to setup the file structure. Then a final cap deploy:check and if that passes, then go for it. cap deploy. Good luck.

In my case I got in trouble because I did not have a javascript runtime library. So I uncommented ruby racer from the Gemfile, and committed that. After that I was running.

Well, forgot one more thing. Deploy was not precompiling the assets. It turns out that line is commented out by default in the Capfile, so I uncommented it and then the stylesheets were showing.

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks