Deployment Infrastructure
Deployment Infrastructure
Section titled “Deployment Infrastructure”Core Idea: Docker Compose orchestrates platform services (RabbitMQ, PostgreSQL, Redis, Jaeger) with devbox for development and isolated containers for production.
Overview
Section titled “Overview”The platform uses Docker for consistent deployment across development and production:
- Development:
docker-compose.ymlwith devbox container - Production: Individual service containers with Docker orchestration
- Infrastructure: Shared services (RabbitMQ, PostgreSQL, Redis, Jaeger, Grafana)
Development Deployment
Section titled “Development Deployment”Start Platform
Section titled “Start Platform”# Start all infrastructure + devboxdocker compose up
# Services started:# - devbox (development environment)# - rabbitmq (message bus)# - postgres (event store)# - redis (cache)# - jaeger (tracing)# - elasticsearch (jaeger backend)# - grafana (dashboards)Access Points
Section titled “Access Points”- Devbox shell:
docker exec -it flow-platform-devbox bash - RabbitMQ UI:
http://localhost:55672(admin/admin123) - Jaeger UI:
http://localhost:16686 - Grafana:
http://localhost:5005(admin/admin) - PostgreSQL:
localhost:55432(actor_user/actor_pass123) - Redis:
localhost:56379
Production Deployment
Section titled “Production Deployment”Service Container
Section titled “Service Container”FROM node:20-alpine
WORKDIR /app
# Install dependenciesCOPY package*.json ./RUN npm ci --only=production
# Copy applicationCOPY dist/ ./dist/
# Run serviceCMD ["node", "dist/main.js"]Environment Variables
Section titled “Environment Variables”# Service configurationNODE_ENV=productionSERVICE_NAME=order-serviceSERVICE_VERSION=1.0.0
# InfrastructureDATABASE_HOST=postgres-productionDATABASE_NAME=eventstoreDATABASE_USER=production_userDATABASE_PASSWORD=<secure-password>RABBITMQ_URL=amqp://production-user:<password>@rabbitmq-cluster:5672REDIS_URL=redis://:<password>@redis-cluster:6379
# TelemetryJAEGER_ENDPOINT=http://jaeger:4318/v1/tracesHealth Checks
Section titled “Health Checks”healthcheck: test: ["CMD", "node", "health-check.js"] interval: 30s timeout: 10s retries: 3 start_period: 40sScaling
Section titled “Scaling”Horizontal Scaling
Section titled “Horizontal Scaling”# Scale service instancesdocker compose up --scale order-service=3
# Load balancing automatic via message bus# Each instance consumes from same queueResource Limits
Section titled “Resource Limits”services: order-service: deploy: resources: limits: cpus: '1.0' memory: 512M reservations: cpus: '0.5' memory: 256MMonitoring
Section titled “Monitoring”Container Health
Section titled “Container Health”# Check container statusdocker ps
# View logsdocker logs flow-platform-devbox
# Resource usagedocker statsInfrastructure Health
Section titled “Infrastructure Health”# RabbitMQdocker exec rabbitmq rabbitmqctl status
# PostgreSQLdocker exec postgres pg_isready
# Redisdocker exec redis redis-cli pingBest Practices
Section titled “Best Practices”-
Use Health Checks
- All services should expose health endpoint
- Platform services respond to health check queries
-
Set Resource Limits
- Prevent resource exhaustion
- Enable auto-scaling triggers
-
Centralized Logging
- All logs to stdout/stderr
- Use logging aggregation (ELK stack)
-
Secrets Management
- Never commit secrets to repository
- Use environment variables or secret management
-
Graceful Shutdown
- Handle SIGTERM signal
- Complete in-flight requests
- Close connections cleanly
Troubleshooting
Section titled “Troubleshooting”Issue: Service Won’t Start
Section titled “Issue: Service Won’t Start”# Check logsdocker logs <container-name>
# Check environmentdocker exec <container-name> env
# Check connectivitydocker exec <container-name> ping postgresIssue: Database Connection Failed
Section titled “Issue: Database Connection Failed”# Verify PostgreSQL runningdocker ps | grep postgres
# Test connectiondocker exec postgres pg_isready
# Check credentialsdocker exec postgres psql -U actor_user -d eventstore -c "SELECT 1"