Skip to content

sheldonh/capsample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

= capsample

My voyage of discovery with Phusion Passenger, Enterprise Ruby, Git and
Capistrano.

These notes started as a literal record of the steps I was taking, but have
evolved into the steps I'd have to take to get the current capsample project.

My deployment server is a Debian Lenny vmware instance called lenny.vmware
(also known as beta.lenny.vmware).

== On lenny.vmware

aptitude install apache2 git-core

Installed Phusion Passenger and Enterprise Ruby into /opt/.

ln -s /opt/ruby-enterprise-*/bin/rake /usr/local/bin/.
ln -s /opt/ruby-enterprise-*/bin/ruby /usr/local/bin/.

Added /etc/hosts entry:

	127.0.1.1	lenny.vmware beta.lenny.vmware

Activated these virtual hosts in apache2:

<VirtualHost *:80>
  ServerName lenny.vmware
  DocumentRoot /var/www/apps/capsample/current/public
  RailsEnv production
</VirtualHost>
<VirtualHost *:80>
  ServerName beta.lenny.vmware
  DocumentRoot /var/www/apps/capsample-beta/current/public
  RailsEnv development
</VirtualHost>

Created capsample and capsample-beta directories in /var/www/apps/.

Created local user sheldonh.

Made sheldonh the owner of the capsample and capsample-beta directories.

== On my workstation

Created a repository called capsample at github.com.

ssh-copy-id -i ~/.ssh/id_dsa.pub sheldonh@lenny.vmware

Add /etc/hosts entry for lenny:

	172.16.103.97	lenny.vmware beta.lenny.vmware

rails capsample
cd capsample

cat >.gitignore <<EOF
db/*.sqlite3
doc/api
doc/app
log/*.log
public/cache/**/*
tmp/**/*
EOF

rake db:schema:dump
script/generate scaffold sample
cp public/stylesheets/scaffold.css .
script/destroy scaffold sample
mkdir -p public/stylesheets
mv scaffold.css public/stylesheets/

The schema dump creates a placeholder schema.rb in the db directory, and the
db directory itself, making sqlite3 easier to deal.  Together with slapping
in a copy of the scaffold stylesheet, we work around having to create
directories explicitly in after_setup and before_finalize_update (empty dirs
aren't tracked by git).

capify .
edit config/deploy.rb
mkdir config/deployments
edit config/deployments/beta.rb
edit config/deployments/production.rb

cat > script/spin <<EOF
#!/bin/true

Capsample currently assumes that a Phusion Passenger virtual host is already
configured with a DocumentRoot like /var/www/apps/capsample/current/public.
EOF
chmod +x script/spin

git init
git add .
git commit -m "Initial import."
git remote add origin git@github.com:sheldonh/capsample.git
git push origin master

cap deploy:setup

	Looked okay except for "zlib(finalizer): the stream was freed
	prematurely." at the end, which I ignored.

cap deploy:check

cap deploy:update

cap deploy:migrate

cap deploy

Browsed to http://lenny.vmware/ and got the "Welcome aboard" page.

Note that the rails "Welcome aboard" page's "About your application's
environment" link only works with RAILS_ENV=development, which I hadn't yet
gotten working at this point.

git checkout -b edge
git remote add origin/edge git@github.com:sheldonh/capsample.git
git push origin/edge edge
cap -S deployment=beta deploy:setup

Browsed to http://beta.lenny.vmware/ and got the "Welcome aboard" page.

Because the beta sites runs in development mode, the "About your application's
environment" link works here.

Now I can deploy edge to the beta site with

	cap -S deployment=beta deploy

and master to the production site with

	cap -S deployment=production deploy

== To do

Handle database.yml, which should be created in a persistent location on
the server and then copied into the current release at deploy:update time.

Test with mysql and postgresql.

About

Sample rails application for testing deployment with Capistrano

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published