Topic: Deploying to DreamHost using Capistrano v2
Hi Everyone
I'm struggling with my first deployment using Capistrano on DreamHost;
The app was deployed within myapp.mydomain.com/myapp/current/public/, which meant that it didn't overwrite my app which was sat at myapp.mydomain.com/myapp/. I knew this was botched, but I thought I try to append my web directory to where Cap was putting my app. However, this just gave me a 'Rails app failed to run' error in my browser - i.e. I didn't know whether it was the deployment that went wrong (the files were there, and no error messages) or whether another setting was stopping the app from running (FastCGI config within the app?).
Thankfully, Subversion seemed to work first time, but I'm confused over how to configure Capistrano v2, and my directories on DH. It didn't help that I was following the Cap manual, which is apparently meant for those using v1.41.
I've started from scratch. Here's where I am now;
a) I have 'myapp' on my local machine. It has been Capified. I haven't configured the deploy.rb, because I need to understand the directories to which I will be deploying.
b) Subversion is configured at svn.mydomain.myapp. The repository hasn't been used yet. I was going to follow the excellent Railcast subversion tutorial video, just as I did last time.
c) I have a subdomain configured for the app at myapp.mydomain.com. When I created the subdomain from the DH control panel, I appended with /current/public/, which means that I now should be serving from myapp.mydomain.com/current/public/. The DH 'quick start' wiki guide ('quick confusion guide', if you ask me) advises that I should now delete the /current/public/ folders that DH has created for me. Is this correct?
d) I'm now under the impression that I need to install a dummy app on DH with which to overwrite when deploying with Capistrano. I want my app to run from myapp.mydomain.com, and I'd prefer it to be installed at myapp.mydomain.com/myapp/. Where should I run 'Rails myapp' within my DH server? Do I need it at the root, or can I plonk it at myapp.mydomain.com/myapp/ and still serve it from myapp.mydomain.com? Is there anything that I need to watch out for when making this decision?
e) It also looks as though I need to make some configuration changes to my local app using the files that are generated by creating a rails app on DreamHost. The wiki says;
1. create a dummy rails app using "rails myapp"
2. copy the created "dispatch.fcgi" into your public/ dir
3. edit the .htaccess .cgi to point to .fcgi (f is for fast):
For step 2, do I copy the 'dispatch.fcgi' into the public/ dir on my local app, or remote app on DH? Same goes for the .htaccess - local or remote copy? Are these configurations maintained after a Cap deployment?
f) Back to the deploy.rb - this is the configuration I am now expecting to use (does it look okay?), based on the tutorial link below;
set :user, 'username'
set :application, "myapp"
set :repository, "http://svn.mydomain.com/myapp/trunk"set :deploy_to, "/home/username/myapp.mydomain.com/"
set :svn_username, "username"role :app, "myapp.mydomain.com"
role :web, "myapp.mydomain.com"
role :db, "myapp.mydomain.com", :primary => truetask :restart_web_server, :roles => :web do
# restart your web server here
endafter "deploy:start", :restart_web_server
g) Another section on the wiki says that I need to include the following to prevent Subversion from installing a .svn folder at the root - as stated, I've already used Subversion, which means I have a /svn/ folder at my root - do I need to include these in deploy.rb and remove my /svn/ folder?
set :use_sudo, false
set :checkout, "export"
set :svn, "/usr/bin/svn"
set :svn_username, Proc.new { "YOUR_SVN_USERNAME --password YOUR_SVN_PASSWORD" }
h) Finally - Am I right in thinking that I keep my database.yml out of Subversion and Capistrano, and that it only be configured for the environment within which it used? I.e. database.yml, inc. production password, on the remote server, and development/test, inc. password, on my local machine? And, if that's the case, do I make the adjustments to the remote app and local app before the first deployment?
That's it! If you can help me out - you're simply awesome. Getting Rails up & running on DreamHost is one of the hardest things I've ever tried.