Deploying without SVN

Subscribe to Deploying without SVN 5 post(s), 4 voice(s)

 
Avatar mikong 5 post(s)

Administrator: (2008-07-19) Step 2 has been updated for compatibility with the new morph_deploy.rb.

MAP currently expects your application to be stored in SVN. If by any chance you want to deploy a locally stored Rails project:

  1. In your morph_deploy.rb, set :repository to a local path. For example:
    set :repository, '~/rails/myapp'
  2. In your morph_deploy.rb, replace this line in task :get_code
    system(strategy.send(:command))
    with the following
    system("cp -R #{repository} #{morph_tmp_dir}")
  3. Optionally, you may also want to update this logging line:
    say("Downloading the code from svn...")
  4. Run the following command in your terminal:
    cap -f morph_deploy.rb morph:deploy

WARNING: DO NOT execute your morph_deploy.rb file in your Rails project directory, or you will have an infinite loop!

NOTE: You’ll have to replace ‘cp -R’ if you’re not working on a *nix-based OS.

 
Avatar Guy Naor Administrator 7 post(s)

Thanks for the great tip!

Coming soon is support for all scm backends supported by capistrano 2.x. Currently: svn, cvs, git, mercurial, accurev, bazaar, perforce and darcs. The script will still default to svn, but can be changed exactly the same way a regular deploy script is, b modifying the set :scm line and other relevant scm entries. It can also be set from the command line with the cap -s options when calling the script. Here are a few examples for deploying using different scms from a local repository:

git: cap -f morph_deploy.rb -s scm=git -s deploy_via=checkout morph:deploy

bazzar: cap -f morph_deploy.rb -s scm=bzr -s repository=’’ morph:deploy

mercurial: cap -f morph_deploy.rb -s scm=mercurial -s deploy_via=checkout -s repository=. morph:deploy

Hope this comes in handy.

Guy.

 
Avatar Guy Naor Administrator 7 post(s)

In addition to the above, current capistrano code in svn (not yet released) has an scm called none that does a copy just like mikong suggested. When that is released (or if you are brave and uses capistrano from svn) you could call it as:

cap -f morph_deploy.rb -s scm=none -s repository=. morph:deploy

Guy.

 
Avatar Zak B. Elep 1 post

I found another way to do SCM-less app deployment, for *nix: instead of using cp(1) for copying the application tree, use tar(1) with its piping feature:


#system(strategy.send(:command))
#instead of system("cp -R #{repository} #{morph_tmp_dir}")
system("mkdir #{morph_tmp_dir}")
system("tar cfp - -C #{repository} --exclude '#{morph_tmp_dir}/.*' . | 
    tar xfp - -C #{morph_tmp_dir}")
This nicely avoids the infinite recursion caused by the morph_tmp_dir inside the application tree, and also allows the morph_deploy.rb script to be in the application root directory as well.
 
Avatar MarkM Administrator 136 post(s)

For Windows users, see this thread.