deprec - install rails stack and deploy in minutes
Update 2007-06-04: Visit www.deprec.org
Until now, installing a full Rails stack on Ubuntu linux and deploying your app took more than a few minutes. The first time I tried it took hours. Even copying and pasting from my notes took forever.
Now with deprec (deployment recipes for Capistrano) you can install a rails stack and deploy your application with just 6 commands.
cd /path/to/railsapp
deprec --apply-to . --name projectname --domain www.projectname.com
# edit config/deploy.rb to put in details of your subversion repository
cap install_rails_stack
cap deprec_setup
cap deploy_with_migrations
cap restart_apache
That's all it takes to get your Rails app running on a default Ubuntu 6.06 server install. Install the gem with:
sudo gem install deprec -y # installs what you need
deprec_dotfiles # patches capistrano + creates your ~/.caprc
cap show_tasks # now you have deprec tasks included
I'll be putting more details up soon on deprec.rubyforge.org
Deprec was inspired and uses the brilliantly executed Capistrano. Thanks Jamis!
After starting on this project I found myself reading and utilizing a lot of
code by Bradley Taylor, in particular the RailsMachine and VMbuilder gems.
Neil Wilson wrote three capistrano plugins that are used in this project.
I'd like to say a huge thanks to these guys for helping make my work easier!
23 comments:
Awesome work! I wanna sign up for a VPS just to give it a run...
Guess I'll have to get parallels fired up with Ubuntu and give it a test.
Thanks!
Be sure to check this earlier post before you waste hours on failed ubuntu servers installs under Parallels.
http://codemode.blogspot.com/2006/11/at-last-ubuntu-server-on-mac-with.html
I installed the Debian netinstall image on Parallels yesterday and it was a breeze.
http://www.us.debian.org/CD/netinst/
Download the stable i386 image and point Parallels at it. You don't even need to burn a CD.
Excellant. I'd be keen to know how much/little needs to be changed to get this to work with Debian.
You can use it to deploy more than one app to the same host. the apache config for each app is stored in appname.conf you they don't squash each other.
You need to specify different ports for mongrel to run on in deploy.rb
Jim, thanks for reporting that. I've changed the offending line and will push out a bugfix today.
To fix yourself in the meantime, change the line in apache.rb to read:
sudo "test ! -f #{index} || sudo mv #{index} #{index}.bak"
Capistrano exits on error if a shell command exits on a non-zero. So I need to use OR in my tests, not AND.
Hi Mike,
Paul from Sydney here. Just wondering how you get to run deprec and install everything from a fresh install of Ubuntu 6.06 - no Subversion, Capistrano, Ruby, anything. I haven't got a Rails app to deploy on it yet, but may well soon. I mainly want to use this as a development server, but will be putting apps into production on it from time to time hopefully. Any advice you have on installing Subversion would be appreciated too.
Thanks for any help at all,
Paul.
Hi Paul,
do you have a workstation to run everything from or are you logging into the server you wish to install the rails stack on directly?
Capistrano is designed for running tasks on remote boxes. There's no reason why you couldn't install openssh, ruby, rubygems, capistrano, deprec and then run them locally but it's not something I would ever do.
I like to have my workstation (MacBook Pro) setup to my liking and then control other boxes from there.
Mike,
I posted a bug to deprec.rubyforge.org for a previous issue, but I can't for the life of me figure out what's going on with my current problem (and I'm not going to file it as a bug as it could easily be a problem with my setup!).
When executing install_rails_stack, I'm dying during the apt-get -qy update call. It seems like it successfully updates most packages, but then dies with the following:
-------------
** [out :: www.slowbicycle.com] Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/dapper/Release Unable to find expected entry unstable/binary-i386/Packages in Meta-index file (malformed Release file?)
** [out :: www.slowbicycle.com] Reading package lists...
** [out :: www.slowbicycle.com] E: Some index files failed to download, they have been ignored, or old ones used instead.
command finished
/usr/lib/ruby/gems/1.8/gems/capistrano/lib/capistrano
/command.rb:45:in `process!': command "sudo sh -c \"DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qy update\""
-----------
I ssh'd to the deployment box and tried the same line, which works without a hitch when I try it directly. Any clues?
hey Stevie. checkout trac.deprecated.org for future bug postings
I've checked your bugfix into svn for the next (overdue!) release.
Not sure what's causing the problem you're currently experiencing.
Many thanks Mike. What you've released is pretty darn impressive, and I'll be stress testing it as much as I can! Hopefully that will include adapting a recipe for an EC2 instance. I'll report back if/when I'm successful...
Also, it asked for a login/password at your trac site, so I wasn't able to check it out.
Thanks for the kind words Stevie. I've turned auth off trac so give it another try. I'm new to trac but am pretty excited by it.
Mike,
Another question about a choice in the deprec codebase. Why include copies of the 3rd party gems instead of using some sort of require statement for a specific version, like:
"require_gem 'mygem', '= 1.0.1'"
Or even using the pessimistic operator to lock to a release but still allow small updates like: "require_gem 'mygem', '~> 1.0'"
(I know "require_gem" is not what you would use, but something along those lines..)
Also, do you have a better forum for deprec discussion somewhere? Blog posting is great for a first volley, but not so helpful for threaded discussions!
Hi Mike, sorry been away. Yes, I have both a server and a workstation. I am totally happy to deploy everything from my laptop, that's great in fact. The less I have to log on to the server and type stuff the better I say.
Hi Mike,
Excellent stuff! I'm trying to use deprec from Windows (I know, glutton for punishment), and I'm having difficulty running deprec_setup. It fails at the call to install_mongrel_start_script with a Net::SFTP::Operations::StatusException.
Looks like it's having a problem doing a put. Any ideas on a way to work/patch around this?
Thanks!
Is it possible to use deprec to deploy a full rails stack on a Fedora Core remote machine? I've only seen references to using it on Ubuntu.
This fellow actually demonstrates the process of running Ubuntu 6.06 LTS in Parallels, installing deprec, and using these commands to do a "remote" installation, deployment, etc.
Unfortunately, when I tried to do the same thing with VMWare Server on Windows XP I hit the same wall that robin did on the Net::SFTP problem. Very sad. I really wanted to use this.
How strange, it filtered out the URL I posted to the video example:
Build a Full Rails Server on Ubuntu
If it strips it out again I'll assume it's just some anti-spam thing run amuck. In which case you can go over to ShowMeDo.com and look under the Ruby videos and you will find it.
I`m having on windows the same problem with net-sftp. It`s a bug or what? Thanks anyway
I had to write you a quick because deprec is friggin' amazing ;)
It is really nice to finally not have to worry about building the rails stack. Not that I can't work my way around my shell and build these things seperate... but deploying Rails should have never been so hard...
Chaining together servers and software the old way wasn't so "Convention over Configuration", right? ;)
I found a bug in su_put that affects Windows users mainly. This is the SFTP exception that everyone's getting!
The first line of su_put builds the remote temp file name, but it checks for the existence of the tmp directory on the local machine. If this directory exists, all is well, if it doesn't (most Windows users), the temp filename is broken and the SFTP error occurs a little later.
The fix is to check for tmp on the remote machine, not the local one.
The workaround is to create a local tmp directory so the test passes.
Despite the minor issues, I'm loving deprec!
I keep getting bash: cap: command not found and deprec: command not found.
Any idea why?
U.
check out www.deprec.org
- Mike
Post a Comment