Staging environments

Published

Updated

🎭

Deploy through multiple stages safely.

An app on fortrabbit holds several environments, such as staging and production. Each one has its own domain, database and Git branch.

About staging environments

A staging environment runs the next version of a site next to production, for testing and sign-off before go-live. On fortrabbit, an app holds several environments, each with its own domain, database, ENV vars and Git branch.

For a small site, a local development environment and production can be enough.

Common setups

  • staging + production: changes go to staging first, get tested, then move to production. The usual setup for client projects with sign-off.
  • temporary + production: an extra environment for a redesign or a major upgrade, deleted afterwards.
  • development + staging + production: development holds the latest changes, staging is for quality assurance, production is live. For teams with continuous integration.

Branches and environments

With Git deployment, each environment follows its own branch, such as develop for staging and main for production. A merge into a branch deploys that environment. See the GitHub App.

Configuration per environment

Frameworks and CMS read the stage from an ENV var, such as APP_ENV in Laravel or CRAFT_ENVIRONMENT in Craft CMS. Set different values per environment in the dashboard: database credentials, mail settings, API keys for test accounts.

Data between environments

Code moves up with Git, but databases and uploads stay in each environment. To test with current content, copy production data to staging:

  • Database: export from production and import into staging, see MySQL export and import.
  • Uploads: download with rsync from production and upload to staging.

Never copy staging data into production without a plan: content created on production in the meantime gets lost.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗