SquareSquash/web — pull request #36 by davidjrice (2013-02-02 18:08:50+00:00)
Title: Use ENV variables for configuration, more upgradable (and Heroku support)

So, I'm aware there's another issue open #33 however, I think the point has been lost amongst using jruby etc. None of that is required **to get it running** on heroku.

The few changes made have allowed me to

* boot the rails app
* create a user
* create a project (using http://username:password@github.com style URL)

Using the following process to create the app.

heroku create
heroku labs:enable user-env-compile

heroku config:add SQUASH_SECRET_TOKEN="xxx"
heroku config:add SQUASH_AUTHENTICATION_PASSWORD_SALT="xxx"
git push heroku master

I'm not happy with where the hacks are to use ENV variables at present. There are more configurations set during `setup.rb` to be extracted and perhaps modifying the setup itself. However, this approach:

* encourages passwords / secret tokens etc. not to be included in the source repository
* allows easy upgradability (as no files are modified this would be as simple as a `git pull && git push heroku`)
* allows configuration changes without requiring deployments

I would use this in conjunction with a `.env` file (added to .gitignore) and instantiating those ENV variables before running the server with

export $(cat .env)

or using the `dot_env` gem.

I would continue further here but the heroku **File System** concerns I've outlaid in #35 have pretty much stopped my progress. I'm not sure running on heroku will be possible without drastic changes to git repository integration.

Therefore, this is more a proof of concept but I thought I would document here as

* a) using ENV variables would still be preferable, regardless of Heroku
* b) if this information helps or inspires anyone else to get this running on Heroku :smiley: