Adding a staging environment to the workflow
First the predispositions, i like to have my heroku git remotes set up as staging and production so you can easily use git push staging/production to deploy to each one of them. I'll be using that setup to explain how to make a staging env.
- create a
config/environments/staging.rb
which you will copy off `config/environments/production.rb' - add a database.yml entry for the staging database(not really needed for heroku but can't hurt)
- Backup your .env file (if you have it)
- Install heroku-config plugin by
heroku plugins:install git://github.com/ddollar/heroku-config.git
- pull your environment settings from heroku(production server) with
heroku config:pull --remote production
- make changes to the .env file and don't forget to add these values to the config:
RACK_ENV=staging RAILS_ENV=staging
so it will use the staging environment configuration. - fork a heroku environment with
heroku fork -a production staging
(those are heroku appnames you want instead of production/staging) - Do a `heroku config:push --remote staging'
- Be sure to deploy the code to staging env properly
You can also read this tutorial, i think i used it to get started with multiple envs on heroku:
https://devcenter.heroku.com/articles/multiple-environments#managing-staging-and-production-configurations
Optimal workflow for Local / Staging / Production server stack + Git
Branches are one way to facilitate this workflow. There is a great blog post about how to use Git branches to manage a typical development workflow.
You would then have one branch for production (e.g. master
), one for the live-edits which correspondes to the hotfix
branch in the post above, and another one for development.
To sync your local environments on laptop and desktop, you can use the aforementioned development
branch also as a remote branch and have both devices push their local commits on this branch to the remote repository.
How to set up a staging environment on Google App Engine
I chose the second option in my set-up, because it was the quickest solution, and I didn't make any script to change the application-parameter on deployment yet.
But the way I see it now, option A is a cleaner solution. You can with a couple of code lines switch the datastore namespace based on the version, which you can get dynamically from the environmental variable CURRENT_VERSION_ID as documented here: http://code.google.com/appengine/docs/python/runtime.html#The_Environment
git with development, staging and production branches
The thought process here is that you spend most of your time in development
. When in development, you create a feature
branch (off of development
), complete the feature, and then merge back into development
. This can then be added to the final production version by merging into production
.
See A Successful Git Branching Model for more detail on this approach.
Related Topics
Rails Model Has_Many , Belongs_To Relations
Find Most Common String in an Array
Generate Letters to Represent Number Using Ruby
Modifying Database Ids from Rails Console
How to Run Rake Tasks Within My Rails Application
Error Installing Gems That Use Native Extensions on Ubuntu, Ruby 1.9.2 via Rvm
Deploying Sinatra App (With Config.Ru) on Heroku Cedar Stack
How to Get the Parent's Class Name in Ruby
How to Password-Protect My /Sidekiq Route (I.E. Require Authentication for the Sidekiq::Web Tool)
Activemodel::Missingattributeerror Occurs After Deploying and Then Goes Away After a While
Fresh Installs of Rvm and Ruby 2.1.1 - Dyld Library/Pathing Error
How to Turn Off Automatic Stylesheet/JavaScript Generation on Rails 3.1
Recommended Approach to Monkey Patching a Class in Ruby
Mountain Lion - Libxml & Nokogiri