Docker Setup Guide¤
This guide explains how to set up and run the AI Goal-Seeking System using Docker Compose with full observability stack for testing and tracing validation.
Architecture Overview¤
The Docker setup includes:
Core Services¤
- Backend: Node.js API with TypeScript, OpenTelemetry tracing
- Frontend: React Native Web app served by Nginx
- Redis: In-memory data structure store for caching and sessions
Observability Stack¤
- Jaeger: Distributed tracing UI and storage
- OpenTelemetry Collector: Telemetry data collection and processing
- Prometheus: Metrics storage and monitoring
- Grafana: Visualization dashboards for metrics and traces
Testing Services¤
- Test Runner: Automated test execution
- Load Test: k6-based performance testing
- Trace Validator: Automated trace validation
Quick Start¤
1. Basic Stack¤
Start the complete stack with observability:
2. With Testing¤
Start stack and run tests:
3. Load Testing¤
Start stack and run load tests:
4. Trace Validation¤
Start stack and validate tracing:
5. Clean Start¤
Clean everything and start fresh:
Service URLs¤
When running in detached mode, access services at:
- Frontend: http://localhost:8080
- Backend API: http://localhost:5001
- Grafana: http://localhost:3000 (admin/admin)
- Jaeger UI: http://localhost:16686
- Prometheus: http://localhost:9090
- Redis: redis://localhost:6379
Manual Docker Compose Commands¤
Basic Operations¤
Start all services:
Stop all services:
View logs:
Build images:
Testing Operations¤
Run with test profile:
Run load tests:
Run trace validation:
Environment Configuration¤
Backend Environment Variables¤
The backend service uses these environment variables:
Frontend Environment Variables¤
Health Checks¤
All services include health checks:
Backend Health Check¤
Frontend Health Check¤
Service Status¤
Testing and Validation¤
Load Testing¤
The load testing uses k6 and includes:
- Health endpoint validation
- API endpoint testing
- Performance metrics collection
- Response time validation
Results are saved to load-test-results.json
.
Trace Validation¤
The trace validation script:
- Waits for all services to be healthy
- Generates test traces by calling API endpoints
- Queries Jaeger to verify traces are collected
- Validates trace data integrity
Running Individual Tests¤
Backend unit tests:
Load test only:
Trace validation only:
Monitoring and Observability¤
Grafana Dashboards¤
Access Grafana at http://localhost:3000:
- Username:
admin
- Password:
admin
Pre-configured data sources:
- Prometheus (metrics)
- Jaeger (traces)
Jaeger Tracing¤
Access Jaeger UI at http://localhost:16686:
- View distributed traces
- Search by service name:
ai-goal-seeking-backend
- Analyze request flows and performance
Prometheus Metrics¤
Access Prometheus at http://localhost:9090:
- Monitor application metrics
- Query custom business metrics
- Set up alerts
Troubleshooting¤
Common Issues¤
-
Port Conflicts
-
Docker Build Failures
-
Service Startup Issues
-
Health Check Failures
Debug Mode¤
Enable debug logging:
Network Issues¤
Test service connectivity:
Development Workflow¤
Hot Reloading¤
For development with hot reloading:
Debugging¤
Access container for debugging:
Production Considerations¤
Security¤
- Services run as non-root users
- Proper signal handling with dumb-init
- Resource limits configured
Performance¤
- Multi-stage builds for smaller images
- Health checks with appropriate intervals
- Restart policies configured
Monitoring¤
- Comprehensive metrics collection
- Distributed tracing enabled
- Log aggregation ready
Cleanup¤
Stop and Remove Everything¤
Or manually: