BrunoMiranda.com

Personal Blog about Software Engineering, Design, Travel & More

Deploying Github repository with Vlad

Posted on May 12, 2008 at 10:38 PM

As many of you are doing, I moved a couple of my source repositories to GitHub. At the moment I have one private and one public.

Here is a simple guide to deploy using vlad. You will need a condig/deploy.rb file:


set :application, "appname"
set :domain,      "domain.com"
set :deploy_to,   "/var/rails/#{application}"
set :scm,         "git"

# use the following with a private repos
# set :repository,  "git@github.com:user/appname.git"

# use the following with a public repos
# set :repository,   "git@github.com:user/appname.git"

set :mongrel_port, 8070
set :mongrel_servers, 2

namespace :vlad do
  desc 'Runs vlad:update, vlad:symlink, vlad:migrate and vlad:start'
  task :deploy => ['vlad:update', 'vlad:symlink', 'vlad:migrate', 'vlad:stop_app', 'vlad:start_app']

  desc 'Symlinks your custom directories'
  remote_task :symlink, :roles => :app do
    run "ln -s #{shared_path}/database.yml #{current_release}/config/database.yml"
  end
end

Possible Gotchas!

If you have Vlad 1.2 installed you will need to add the following to your Rakefile

begin
  require 'vlad'
  Vlad.load :scm => "git"
rescue LoadError
  # do nothing
end

If you run into the following error:

fatal: You must specify an archive format

It is probably because you installed git-core with sudo apt-get install git-core. The reason for that is apt-get install git-core installs a 1.4x version of git on your Ubuntu machine, and a default for git archive was added in a later version. Thankfully the solution is pretty simple. Remove the previously installed version of git-core and install a newer version from source.

sudo apt-get remove git-core
wget http://kernel.org/pub/software/scm/git/git-1.5.5.1.tar.bz2
sudo apt-get build-dep git-core
tar xjf git-1.5.5.1.tar.bz2
cd git-1.5.5.1/
./configure --with-tcltk
make
sudo make install

Use –with-tcltk since there is no need to install GUI on the server.

If you do however want to install GUI for some reason you will need to install gettext and start the the git-core installation from source from the beginning.

sudo apt-get install gettext

Now all you have left is to run setup and then deploy:

rake vlad:setup

and

rake vlad:deploy

Deploying a Private Repos

Make sure you go into the server, generate an ssh key for the deployment user and paste the public key into the Github’s deploy key. You will also need to go into the server and clone the repos so that the ssh key pair is generated. Make sure the public key on the server is owned by the deploy user and the permissions are correct:

chown deploy:deploy id_rsa.pub

and

chmod 600 id_rsa.pub

Let me know if you encounter any issues with the instructions above.

Hierarchy: previous, next

Comments

There are 2 comments on this post. Post yours →

Markus

Should it be –without-tcltk if you don’t need the gui?


Could you give a little more detail about the server side?

I get an error when trying to clone to my production server: Permission denied (publickey).

  1. I generated a new key without a passphrase
  2. I uploaded it to the server and chmod’d to 600
  3. Added it to authorized_keys
  4. Added the key to the repos on github
  5. Made sure ssh-agent was running
  6. ssh-add’d the key - got error: ‘Could not open a connection to your authentication’

Thanks!

Post a comment

Required fields in bold.

 

Visit the Archives →