Skip to content

Deployment Guide

This guide provides comprehensive instructions for deploying the Grit One SDK to production environments.

Prerequisites

Before deploying, ensure you have:

  • Python 3.11 or higher installed
  • Docker installed and running
  • AWS CLI configured with appropriate credentials
  • Required environment variables set (see Configuration section)

Deployment Process

1. Build Docker Image

The first step is to build the Docker image containing your application:

python scripts.py build_image

This command: - Creates a production-ready Docker image - Optimizes dependencies and removes development packages - Tags the image with the current version - Performs health checks on the built image

2. Deploy to Production

Deploy the built image to your production environment:

python scripts.py deploy

This command: - Pushes the Docker image to the configured container registry - Updates the deployment configuration - Performs a rolling update to minimize downtime - Validates the deployment health

Configuration

Environment Variables

Set the following environment variables before deployment:

# AWS Configuration
export AWS_REGION=us-east-1
export AWS_ACCOUNT_ID=your-account-id

# Application Configuration
export APP_ENV=production
export DJANGO_SETTINGS_MODULE=core.settings

# Database Configuration
export DATABASE_URL=your-database-url

# Container Registry
export ECR_REPOSITORY=your-ecr-repository

Deployment Configuration File

Create a deploy.yml file in your project root:

version: '1.0'
deployment:
  name: grit-app-run
  region: us-east-1
  service:
    cpu: 512
    memory: 1024
    min_instances: 2
    max_instances: 10
  health_check:
    path: /health
    interval: 30
    timeout: 5
    retries: 3

Troubleshooting

Common Issues

  1. Build Failures
  2. Check Docker daemon is running
  3. Verify Dockerfile syntax
  4. Ensure all dependencies are specified in requirements.txt

  5. Deployment Failures

  6. Verify AWS credentials and permissions
  7. Check container registry accessibility
  8. Validate environment variables

  9. Health Check Failures

  10. Ensure health endpoint is accessible
  11. Check application startup time
  12. Verify database connectivity

Debug Mode

Run deployment in debug mode for verbose output:

python scripts.py deploy --debug

Security Considerations

  • Never commit sensitive environment variables to version control
  • Use AWS Secrets Manager or Parameter Store for secrets
  • Enable container image scanning
  • Implement least-privilege IAM policies
  • Use HTTPS for all endpoints

CI/CD Integration

GitHub Actions Example

name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Build and Deploy
        run: |
          python scripts.py build_image
          python scripts.py deploy

Post-Deployment Steps

  1. Verify application functionality
  2. Run smoke tests
  3. Monitor error rates and performance metrics
  4. Update documentation with deployment details
  5. Notify stakeholders of successful deployment