Skip to content

Deployment Automation Guide

Overview

DSTA uses automated deployment with blue-green strategy for zero-downtime deployments.

Deployment Scripts

Production Deployment

./scripts/deploy.sh

Features: - Blue-green deployment - Automatic health checks - Automatic rollback on failure - Slack notifications - Database migrations - Static file collection

Staging Deployment

./scripts/deploy-staging.sh

Features: - Quick deployment for testing - Health checks - Migration execution

CI/CD Pipeline

GitHub Actions workflow: .github/workflows/deploy.yml

Workflow Stages

  1. Test: Run unit tests and code coverage
  2. Build: Build Docker images for all services
  3. Deploy Staging: Automatic deployment to staging on main branch
  4. Deploy Production: Manual approval for production deployment

Triggers

  • Push to main: Deploy to staging
  • Version tags (v..*): Deploy to production
  • Manual dispatch: Deploy to selected environment

Blue-Green Deployment

The production deployment uses blue-green strategy:

  1. Build new images (green)
  2. Run database migrations
  3. Scale up new instances
  4. Health check new instances
  5. Switch traffic to new instances
  6. Scale down old instances (blue)
  7. Cleanup

Health Checks

All deployments verify: - HTTP endpoint accessibility - API response validity - Database connectivity - Service availability

Rollback

Automatic rollback on: - Health check failure - Migration errors - Service start failure

Manual rollback:

docker tag dsta-api:previous dsta-api:latest
docker-compose -f docker-compose.prod.yml up -d

Notifications

Slack notifications sent for: - Deployment start - Deployment success - Deployment failure - Rollback events

Configure webhook: SLACK_WEBHOOK_URL environment variable

Secrets Management

Required GitHub Secrets: - STAGING_HOST: Staging server hostname - STAGING_USERNAME: SSH username - STAGING_SSH_KEY: SSH private key - PRODUCTION_HOST: Production server hostname - PRODUCTION_USERNAME: SSH username
- PRODUCTION_SSH_KEY: SSH private key - SLACK_WEBHOOK_URL: Slack webhook for notifications

Monitoring

Monitor deployments: - GitHub Actions: https://github.com/your-repo/actions - Slack: #dsta-deployments channel - Grafana: Deployment annotations

Best Practices

  1. Always deploy to staging first
  2. Run smoke tests after staging deployment
  3. Monitor metrics after production deployment
  4. Keep deployment scripts in version control
  5. Document deployment changes

Troubleshooting

Deployment Fails

Check logs:

docker-compose -f docker-compose.prod.yml logs api-server

Health Check Fails

Verify endpoint:

curl -v http://localhost:8000/health/

Rollback Needed

Manual rollback:

./scripts/deploy.sh  # Will auto-rollback on failure

Version History

  • 1.0.0 (2025-01-27): Initial deployment automation