This directory contains configuration and deployment files for Nova Rewards DevOps infrastructure. It implements solutions for logging, secret management, CDN, and staging environment.
infrastructure/
├── logging/ # Centralized logging with Loki, Prometheus, Grafana
├── secrets/ # Secret management with Vault and AWS Secrets Manager
├── cdn/ # CDN configuration with CloudFront and Cloudflare
├── staging/ # Staging environment setup with preview deployments
└── ssl/ # SSL/TLS certificate management
logging/loki-config.yml - Loki configurationlogging/docker-compose-logging.yml - Complete logging stacklogging/prometheus.yml - Metrics scrapinglogging/promtail-config.yml - Log collectionlogging/alertmanager.yml - Alert ruleslogging/alert_rules.yml - Prometheus alert conditionsQuick Start:
cd infrastructure/logging
docker-compose -f docker-compose-logging.yml up -d
# Access Grafana at http://localhost:3000 (admin/admin)
# Access Loki UI at http://localhost:3100
secrets/vault-config.hcl - Vault server configurationsecrets/docker-compose-secrets.yml - Vault stacksecrets/vault-policies.hcl - RBAC policiessecrets/secret-rotator.sh - Rotation scriptQuick Start:
cd infrastructure/secrets
docker-compose -f docker-compose-secrets.yml --profile setup up
# Initialize and unseal Vault
# Access Vault UI at http://localhost:8200 (requires token)
Secret Rotation:
cdn/terraform-cdn.tf - CloudFront + Cloudflare setupcdn/CLOUDFLARE_SETUP.md - Manual configuration guideCache Rules:
Static Assets (images, fonts):
- Cache: 1 year
- Compression: Enabled
HTML/CSS/JS:
- Cache: 30 days
- Compression: Brotli enabled
API Endpoints (/api/*):
- Cache: Disabled
- Bypass cache on all requests
DDoS Protection:
Deployment:
cd terraform
terraform init
terraform plan -var-file=cdn.tfvars
terraform apply -var-file=cdn.tfvars
staging/docker-compose-staging.yml - Staging stackstaging/seed-staging-db.sh - Data seeding scriptstaging/nginx-staging.conf - Reverse proxy config.github/workflows/preview-deployment.yml - PR preview workflowQuick Start:
cd infrastructure/staging
docker-compose -f docker-compose-staging.yml up -d
./seed-staging-db.sh seed
# Access at http://localhost
Preview Deployments (Automated via GitHub Actions):
Seed Data Includes:
# Deploy logging stack
docker-compose -f infrastructure/logging/docker-compose-logging.yml up -d
# Configure application to send logs
export LOKI_URL=http://localhost:3100
export PROMETHEUS_URL=http://localhost:9090
# Deploy Vault
docker-compose -f infrastructure/secrets/docker-compose-secrets.yml up -d
# Initialize Vault (one-time)
vault operator init
vault operator unseal [key1] [key2] [key3]
# Apply policies
vault policy write admin infrastructure/secrets/vault-policies.hcl
# Start secret rotator
docker-compose -f infrastructure/secrets/docker-compose-secrets.yml up -d secret-rotator
# Set environment variables
export CLOUDFLARE_API_TOKEN=<your-token>
export TF_VAR_cloudflare_api_token=<your-token>
# Deploy infrastructure
cd terraform
terraform apply -var-file=cdn.tfvars
# Start staging environment
docker-compose -f infrastructure/staging/docker-compose-staging.yml up -d
# Seed test data
infrastructure/staging/seed-staging-db.sh seed
# Clear test data
infrastructure/staging/seed-staging-db.sh clear
- HTTP Error Rate > 5% for 5 minutes
- P99 Latency > 1 second for 5 minutes
- Database Connection Pool > 90% utilized
- Disk Space < 10% remaining
- Memory Usage > 85%
- Loki unavailable > 5 minutes
- Alertmanager unavailable > 5 minutes
| Metric | Target | Alert Threshold |
|---|---|---|
| API Response Time (p99) | < 500ms | > 1000ms |
| Error Rate | < 0.1% | > 5% |
| Cache Hit Rate | > 70% | < 50% |
| Availability | 99.9% | < 99.5% |
| Log Ingestion Latency | < 5s | > 30s |
# Check Loki health
curl http://localhost:3100/ready
# View Loki logs
docker logs loki
# Test Promtail connectivity
docker logs promtail
# Check Prometheus targets
curl http://localhost:9090/api/v1/targets
# Check Vault status
vault status
# Verify policies
vault policy list
vault policy read admin
# Check secret rotator logs
docker logs secret-rotator
# Manual secret rotation
vault read database/creds/postgres
# Check CloudFront distribution
aws cloudfront get-distribution --id <distribution-id>
# Test Cloudflare cache
curl -I https://nova-rewards.com
curl -v -H "CF-Cache-Status" https://nova-rewards.com
# View cache analytics
# Via Cloudflare dashboard: Analytics > Traffic
# Check database connection
docker exec postgres-staging psql -U staging_user -d nova_rewards_staging -c "SELECT 1"
# View backend logs
docker logs backend-staging
# Check frontend health
curl http://localhost/health
# Test API
curl http://localhost/api/health
See LICENSE file in the repository root.