Sly
Sly

Reputation: 733

Developing & deploying Rails app from same machine

I have started developing a new Rails app on my server using RVM, Rails 3, & Ruby v1.9.2. I am using Git as my code repository. It's a simple app and I don't want to use an extra server. I just want to deploy my app directly from the same server I am developing on.

I've installed Phusion Passenger w/ Apache to serve my app, but have realized that I can't do that pointing to my development directory as my RAILS_ENV is set to "development". (I found I got file permission errors on the asset pipeline and other issues when I attempted to set RAILS_ENV to "production" and serve the app)

What's the simplest/easiest way to deploy the app? Can I simply: 1) Create a separate user to run rails production (Rails in dev currently runs as me on my Ubuntu server) 2) Clone my repo into a separate dir and configure Apache accordingly 3) Seed my database with the data needed for production (not much data needed here) 4) What else?

I've looked briefly at Capistrano, but it seems like overkill for this simple app. I only need to be able to provide a simple web interface for some data entry. Seems like git push should be sufficient, but I haven't done this before so maybe I'm wrong? Also, if I git push how do I ensure file permissions in the "production" directories are all set properly, particularly for any new files that get created in the originating app directory structure?

Thanks for any ideas.

Upvotes: 1

Views: 317

Answers (1)

Michael De Silva
Michael De Silva

Reputation: 3818

No- you do not need Capistrano for the above; at this stage I feel it will only serve to confuse you further.

I'd suggest you first save your repo to a private Github or free BitBucket account. What you should do is keep one folder for 'development'.

Remember that Passenger is 'just' a module working with Apache. So what you need to do is setup a virtual host under apache and direct that to another folder on your system. For this example, consider:

~/rails/myapp_development/ and ~/rails/myapp_production/

Passenger always runs the app in production, so that should not be an issue. You can do bundle --without=production in your development setup to ignore any gems listed in the Gemfile under the production namespace, i.e. say you've got the mysql adaptor specified, you can ignore this and have Rails only rely on the SQlite gem.

You can now simply develop in the development folder, commit, push to BitBucket. Deploying will be as simply going into the production folder and doing a git pull and touch tmp/restart.txt.

Upvotes: 2

Related Questions