Stages Pattern ๐ญ
Overview ๐
This pattern describes the three-stage deployment model: Development (dev), QA (staging), and Production (prod). Each stage serves specific purposes in the software development lifecycle and has distinct characteristics and requirements.
Goals ๐ฏ
- Clear separation of development, testing, and production workloads
- Consistent progression of changes through environments
- Reliable testing and QA processes
- Protected production environment
- Traceable deployments
Stage Definitions ๐
Development (dev) ๐ป
Purpose: Active development and integration testing
Characteristics
- ๐ง Reflects current development state
- ๐ฟ Deployed from dev branches
- ๐งช Allows experimental features
- ๐ Frequent updates
- ๐ฆ Latest dependencies
Configuration
# dev environment configurationenvironment: developmentdebug: truelog_level: debugfeature_flags: experimental: enabled
QA (staging) ๐งช
Purpose: Quality assurance and pre-production verification
Characteristics
- ๐ Mirrors production setup
- ๐ QA testing environment
- ๐ Production data copies (anonymized)
- ๐ฟ Deployed from main branch
- ๐ Regular but controlled updates
Configuration
# staging environment configurationenvironment: stagingdebug: falselog_level: infofeature_flags: experimental: configurable
Production (prod) ๐
Purpose: Live system serving real users
Characteristics
- โ Stable and verified code
- ๐ท๏ธ Deployed from version tags
- ๐ Strict access control
- ๐ Production monitoring
- ๐ Security hardening
Configuration
# production environment configurationenvironment: productiondebug: falselog_level: warnfeature_flags: experimental: disabled
Workflow ๐
Code Progression
graph LR A[dev Branch] --> B[main Branch] --> C[Version Tag] A --> D[dev Environment] B --> E[staging Environment] C --> G[Change] --> F[prod Environment]
Database Handling
Database state is exported from production into the backup system. From there a backup is imported into a fresh staging environment.
Access Control Matrix ๐
Resource | Dev | Staging | Production |
---|---|---|---|
Environment Access | ๐ด Only Team and Stakeholders | ๐ด Only Team and Stakeholders | ๐ข Users |
Deployment trigger | ๐ข Dev-Branch Commit | ๐ก Signed maintainer commit after merge | ๐ด Signed Version Release |
Quality Gates
Development to Staging
- โ All tests passing
- โ Code review completed
- โ Main branch merge
- โ Automated deployment
Staging to Production
- โ QA approval
- โ Performance testing
- โ Security scan
- โ Version tagged
- โ Release notes
- โ Deployment plan
Anti-patterns to Avoid โ ๏ธ
- โ Bypassing staging environment
- โ Using production data in development
- โ Manual configuration changes
- โ Inconsistent environments
- โ Direct production hotfixes
Best Practices ๐ก
- ๐ฆ Use infrastructure as code
- ๐ Automate deployment processes
- ๐ Maintain environment parity
- ๐ Regular staging refreshes
- ๐ Strict access control
- ๐ Comprehensive logging
- ๐ฏ Feature flags for control
Environment Setup Checklist ๐
- Infrastructure provisioned
- Security groups configured
- Monitoring enabled
- Backup strategy implemented
- Access control configured
- Deployment pipeline tested
- Documentation updated
Related Patterns ๐
- ๐ Deployment Pipeline
- ๐ Access Control
- ๐ Monitoring Strategy
- ๐๏ธ Database Management
- ๐ Change Management