Date: August 11, 2025 Status: Production Ready Environment: Staging with Docker Compose Performance: <500ms search target (achieving ~60ms)
This guide covers the deployment of Piper Morgan to the staging environment, which provides a production-grade testing environment for MCP integration, performance validation, and deployment verification.
# Deploy complete staging environment
./scripts/deploy_staging.sh
# Verify deployment (14 comprehensive tests)
./scripts/verify_staging_deployment.sh
# Build and start services
docker-compose build
docker-compose up -d
# Verify all services are running
docker-compose ps
The staging environment consists of 8 containerized services:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Nginx Proxy │ │ Piper Morgan │ │ PostgreSQL │
│ Port: 8081 │◄──►│ Port: 8001 │◄──►│ Port: 5432 │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
│ │ Redis │ │
│ │ Port: 6379 │ │
│ └─────────────────┘ │
│ │ │
│ ┌─────────────────┐ │
│ │ ChromaDB │ │
│ │ Port: 8000 │ │
│ └─────────────────┘ │
│ │ │
│ ┌─────────────────┐ │
│ │ Prometheus │ │
│ │ Port: 9090 │ │
│ └─────────────────┘ │
│ │ │
│ ┌─────────────────┐ │
│ │ Grafana │ │
│ │ Port: 3001 │ │
│ └─────────────────┘ │
│ │ │
│ ┌─────────────────┐ │
│ │ Health Check │ │
│ │ Port: 8002 │ │
│ └─────────────────┘ │
# Copy and configure environment template
cp .env.example .env
# Key configuration variables
POSTGRES_DB=piper_morgan_staging
POSTGRES_USER=piper_user
POSTGRES_PASSWORD=secure_password_here
REDIS_URL=redis://redis:6379
CHROMA_HOST=chromadb
CHROMA_PORT=8000
# Key service configurations
services:
app:
build: .
ports:
- "8001:8000"
environment:
- ENVIRONMENT=staging
- LOG_LEVEL=INFO
depends_on:
- postgres
- redis
- chromadb
nginx:
image: nginx:alpine
ports:
- "8081:80"
volumes:
- ./nginx/staging.conf:/etc/nginx/nginx.conf
# Verify system requirements
./scripts/check_system_requirements.sh
# Check port availability
./scripts/check_port_availability.sh
# Validate Docker installation
docker --version
docker-compose --version
# Initialize PostgreSQL database
docker-compose exec postgres psql -U piper_user -d piper_morgan_staging -f /docker-entrypoint-initdb.d/init.sql
# Verify database connection
docker-compose exec app python -c "from services.database import get_db; print('Database connection successful')"
# Start core services
docker-compose up -d postgres redis chromadb
# Wait for services to be ready
./scripts/wait_for_services.sh
# Deploy application
docker-compose up -d app
# Deploy monitoring stack
docker-compose up -d prometheus grafana
# Run comprehensive health checks
./scripts/verify_staging_deployment.sh
# Expected output: 14/14 tests passing
http://localhost:8001/healthhttp://localhost:8001/health/dbhttp://localhost:8001/health/redishttp://localhost:8001/health/mcpAccess Grafana at http://localhost:3001 (admin/admin):
# Check service logs
docker-compose logs [service_name]
# Verify port conflicts
netstat -tulpn | grep :8001
# Check resource usage
docker stats
# Verify PostgreSQL is running
docker-compose exec postgres pg_isready
# Check connection parameters
docker-compose exec app python -c "import os; print(os.getenv('DATABASE_URL'))"
# Check MCP connection pool status
curl http://localhost:8001/health/mcp
# Monitor resource usage
docker stats --no-stream
# Restart specific service
docker-compose restart [service_name]
# Restart all services
docker-compose restart
# Backup current data
docker-compose exec postgres pg_dump -U piper_user piper_morgan_staging > backup.sql
# Restore from backup
docker-compose exec -T postgres psql -U piper_user -d piper_morgan_staging < backup.sql
The staging environment includes automatic rollback capabilities:
# Trigger rollback to previous version
./scripts/rollback_staging.sh
# Verify rollback success
./scripts/verify_staging_deployment.sh
# Stop current deployment
docker-compose down
# Restore previous version
git checkout HEAD~1
docker-compose up -d
# Verify rollback
./scripts/verify_staging_deployment.sh
# Monitor connection pool status
curl http://localhost:8001/health/mcp
# Expected metrics:
# - Active connections: 5-10
# - Pool size: 20
# - Connection wait time: <10ms
# Check query performance
docker-compose exec postgres psql -U piper_user -d piper_morgan_staging -c "SELECT * FROM pg_stat_statements ORDER BY mean_time DESC LIMIT 10;"
# Automated daily backup
0 2 * * * /scripts/backup_staging.sh
# Manual backup
./scripts/backup_staging.sh
# Restore from backup
./scripts/restore_staging.sh backup_2025-08-11.sql
# Quick status check
./scripts/staging_status.sh
# Performance test
./scripts/performance_test.sh
# Full system reset
./scripts/reset_staging.sh
Status: Production Ready ✅ Performance: <500ms target (achieving ~60ms) ✅ Monitoring: Comprehensive health checks ✅ Rollback: Automated recovery procedures ✅