Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a staging environment to the workflow [closed]

Tags:

I currently have two environments in which I work: development locally and production on Heroku.

I would like to add a staging environment on Heroku to see that everything goes as expected before pushing the app live to users. Preferably, the staging environment should have the exact same settings and data as the production environment.

What are the steps needed to accomplish the above?

like image 269
Fellow Stranger Avatar asked Oct 13 '13 10:10

Fellow Stranger


People also ask

What are the benefits of keeping the staging environment?

Staging environment allows the testers to examine the product on a near-production level in a non-production environment. It offers a platform where the developers can perform an ultimate quality assurance check. This ensures that users get the best quality.

What is the purpose of a staging environment?

A staging environment (stage) is a nearly exact replica of a production environment for software testing. Staging environments are made to test codes, builds, and updates to ensure quality under a production-like environment before application deployment.

Is staging environment necessary?

Think of it as a safe space where you can throw everything together and find out how it works. And to ensure your product performs exactly how you expect it to in the real world, you need both a testing and staging environment. The testing environment helps you ensure that each component does its job.


1 Answers

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.

  1. create a config/environments/staging.rb which you will copy off `config/environments/production.rb'
  2. add a database.yml entry for the staging database(not really needed for heroku but can't hurt)
  3. Backup your .env file (if you have it)
  4. Install heroku-config plugin by heroku plugins:install git://github.com/ddollar/heroku-config.git
  5. pull your environment settings from heroku(production server) with heroku config:pull --remote production
  6. 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.
  7. fork a heroku environment with heroku fork -a production staging (those are heroku appnames you want instead of production/staging)
  8. Do a `heroku config:push --remote staging'
  9. 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

like image 152
berislavbabic Avatar answered Sep 22 '22 00:09

berislavbabic