Theory: The fewer long-lived environments the better
Theory: The fewer long-lived environments the better.
I prefer having only one long-lived environment - Production.
Here's my ideal 3 step workflow:
1. Code on my local machine. Spin up the environment via a single command. Each dev has their own DB instance(s), populated via scripts checked into source control, and a simple command to reset the DB to support reliable automated testing. Everything runs local - no internet required.
2. When I create a branch, a "Preview deployment" (also known as an ephemeral environment) is automatically created and deployed to a unique URL. (For example, Vercel does this). Code reviews, demos, QA, and user acceptance tests use the preview URL. This way, code is fully vetted and approved for prod *before* merge. This shifts quality left and encourages frequent inspection and collaboration.
3. If all tests pass on CI, I merge my PR to main and it auto-deploys to prod. I feature flag if I need to limit who sees the new feature.
Notice what I don't need with this approach? No long-lived Dev, Sandbox, QA, UAT, or Staging environments. These environments lead to batching and coordination overhead, and generally fight against continuous delivery.
Often automated preview deployments and prod are all that's needed.