Node.js: Version 18.0+ (for local development)
Git: Latest version
# Clone the repository
git clone <repository-url>
cd advanced-analytics-platform
# Verify Docker installation
docker --version
docker-compose --version
# Copy environment template (if exists)
cp .env.example .env
# Edit environment variables
nano .env
Required Environment Variables:
# Database
POSTGRES_PASSWORD=your_secure_password
REDIS_PASSWORD=your_redis_password
# JWT Security
JWT_SECRET=your-super-secret-jwt-key-change-in-production
# API URLs
VITE_API_URL=http://localhost:3001
VITE_ML_SERVICE_URL=http://localhost:8001
# Start all services in development mode
npm run docker:dev
# Or start in detached mode
docker-compose -f docker-compose.dev.yml up -d
# Wait for services to be healthy (2-3 minutes)
docker-compose -f docker-compose.dev.yml ps
# Initialize equipment profiles and sample data
curl -X POST http://localhost:3001/api/equipment/initialize \
-H "Authorization: Bearer <admin-token>"
1. Prerequisites Installation
# Install Docker (Ubuntu/Debian)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Install Node.js (for local development)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
2. Project Setup
# Clone and navigate
git clone <repository-url>
cd advanced-analytics-platform
# Install dependencies (optional for Docker-only deployment)
npm install
# Build shared packages
npm run build:shared
3. Service Configuration
# Create necessary directories
mkdir -p logs uploads/data
# Set proper permissions
chmod 755 logs uploads
# Create Docker networks (if needed)
docker network create analytics-platform-network
1. Security Hardening
# Generate secure passwords
openssl rand -base64 32 # For JWT_SECRET
openssl rand -base64 16 # For database passwords
# Create production environment file
cat > .env.production << EOF
NODE_ENV=production
JWT_SECRET=$(openssl rand -base64 32)
POSTGRES_PASSWORD=$(openssl rand -base64 16)
REDIS_PASSWORD=$(openssl rand -base64 16)
MINIO_ROOT_PASSWORD=$(openssl rand -base64 16)
EOF
2. SSL/TLS Configuration
# Create SSL certificates directory
mkdir -p ssl
# Generate self-signed certificates (for testing)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout ssl/private.key -out ssl/certificate.crt
# Or use Let's Encrypt for production
# certbot certonly --standalone -d your-domain.com
3. Production Docker Compose
Create docker-compose.prod.yml:
version: '3.8'
services:
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./ssl:/etc/nginx/ssl
depends_on:
- frontend
- backend
# ... other services with production configurations
Development Mode
# Start all services
docker-compose -f docker-compose.dev.yml up
# Start specific services
docker-compose -f docker-compose.dev.yml up postgres redis
# Start in background
docker-compose -f docker-compose.dev.yml up -d
Production Mode
# Start production environment
docker-compose -f docker-compose.prod.yml up -d
# Check service status
docker-compose -f docker-compose.prod.yml ps
# Graceful shutdown
docker-compose -f docker-compose.dev.yml down
# Stop and remove volumes (⚠️ DATA LOSS)
docker-compose -f docker-compose.dev.yml down -v
# Force stop all containers
docker-compose -f docker-compose.dev.yml kill
Individual Service Control
# Restart specific service
docker-compose -f docker-compose.dev.yml restart backend
# View service logs
docker-compose -f docker-compose.dev.yml logs -f backend
# Scale services
docker-compose -f docker-compose.dev.yml up -d --scale backend=3
Health Monitoring
# Check all service health
curl http://localhost:3001/health
# Check database connectivity
docker-compose -f docker-compose.dev.yml exec postgres pg_isready
# Check Redis connectivity
docker-compose -f docker-compose.dev.yml exec redis redis-cli ping
1. Backend API Health
# Health endpoint
curl -X GET http://localhost:3001/health
# Expected response:
{
"status": "ok",
"timestamp": "2024-01-15T10:30:00.000Z",
"database": {
"postgres": true,
"redis": true
}
}
2. Database Connectivity
# PostgreSQL connection test
docker-compose -f docker-compose.dev.yml exec postgres \
psql -U postgres -d analytics_platform -c "SELECT version();"
# Redis connection test
docker-compose -f docker-compose.dev.yml exec redis \
redis-cli ping
3. Frontend Accessibility
# Check frontend is serving
curl -I http://localhost:3000
# Expected: HTTP/1.1 200 OK
1. Authentication Test
# Register new user
curl -X POST http://localhost:3001/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "test@example.com",
"password": "password123",
"firstName": "Test",
"lastName": "User"
}'
# Login
curl -X POST http://localhost:3001/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"password": "password123"
}'
2. Data Upload Test
# Create test CSV file
echo "timestamp,temperature,pressure
2024-01-01T00:00:00Z,125.5,2.45
2024-01-01T00:01:00Z,126.2,2.48" > test_data.csv
# Upload test file
curl -X POST http://localhost:3001/api/data/upload \
-H "Authorization: Bearer <your-token>" \
-F "file=@test_data.csv"
3. Equipment Initialization
# Initialize equipment profiles
curl -X POST http://localhost:3001/api/equipment/initialize \
-H "Authorization: Bearer <admin-token>"
# Verify equipment list
curl -X GET http://localhost:3001/api/equipment \
-H "Authorization: Bearer <your-token>"
1. Services Won't Start
# Check Docker daemon
sudo systemctl status docker
# Check port conflicts
netstat -tulpn | grep :3001
# Check disk space
df -h
# View detailed logs
docker-compose -f docker-compose.dev.yml logs --tail=50
2. Database Connection Issues
# Check PostgreSQL logs
docker-compose -f docker-compose.dev.yml logs postgres
# Reset database
docker-compose -f docker-compose.dev.yml down
docker volume rm advanced-analytics-platform_postgres_data
docker-compose -f docker-compose.dev.yml up -d postgres
3. Frontend Build Issues
# Clear node modules and rebuild
docker-compose -f docker-compose.dev.yml exec frontend rm -rf node_modules
docker-compose -f docker-compose.dev.yml restart frontend
# Check frontend logs
docker-compose -f docker-compose.dev.yml logs frontend
1. Memory Usage
# Check container memory usage
docker stats
# Increase Docker memory limit
# Docker Desktop: Settings > Resources > Memory
2. Database Performance
# Check database connections
docker-compose -f docker-compose.dev.yml exec postgres \
psql -U postgres -d analytics_platform \
-c "SELECT count(*) FROM pg_stat_activity;"
# Analyze slow queries
docker-compose -f docker-compose.dev.yml exec postgres \
psql -U postgres -d analytics_platform \
-c "SELECT query, mean_time FROM pg_stat_statements ORDER BY mean_time DESC LIMIT 10;"
1. Log Locations
# Application logs
docker-compose -f docker-compose.dev.yml logs backend > backend.log
# Database logs
docker-compose -f docker-compose.dev.yml logs postgres > postgres.log
# System logs
journalctl -u docker.service > docker.log
2. Log Rotation
# Configure Docker log rotation
cat > /etc/docker/daemon.json << EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
EOF
sudo systemctl restart docker
1. Database Backup
# Create backup
docker-compose -f docker-compose.dev.yml exec postgres \
pg_dump -U postgres analytics_platform > backup_$(date +%Y%m%d_%H%M%S).sql
# Automated backup script
cat > backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/backups"
DATE=$(date +%Y%m%d_%H%M%S)
docker-compose -f docker-compose.dev.yml exec -T postgres \
pg_dump -U postgres analytics_platform > "$BACKUP_DIR/backup_$DATE.sql"
find $BACKUP_DIR -name "backup_*.sql" -mtime +7 -delete
EOF
chmod +x backup.sh
2. Volume Backup
# Backup all volumes
docker run --rm -v advanced-analytics-platform_postgres_data:/data \
-v $(pwd)/backups:/backup alpine \
tar czf /backup/postgres_data_$(date +%Y%m%d).tar.gz -C /data .
1. Application Updates
# Pull latest images
docker-compose -f docker-compose.dev.yml pull
# Restart with new images
docker-compose -f docker-compose.dev.yml up -d
# Clean old images
docker image prune -f
2. Database Migrations
# Run database migrations
docker-compose -f docker-compose.dev.yml exec backend \
npm run migrate
# Verify migration status
docker-compose -f docker-compose.dev.yml exec postgres \
psql -U postgres -d analytics_platform \
-c "SELECT * FROM schema_migrations;"
[ ] Change all default passwords
[ ] Generate secure JWT secret
[ ] Configure SSL/TLS certificates
[ ] Set up firewall rules
[ ] Enable audit logging
[ ] Configure backup encryption
[ ] Set up monitoring alerts
[ ] Review user permissions
[ ] Enable rate limiting
[ ] Configure CORS properly
[ ] Regular security updates
[ ] Monitor access logs
[ ] Review user accounts monthly
[ ] Backup verification
[ ] Security scan quarterly
[ ] Password policy enforcement
System Down: Check service status, restart if needed
Data Loss: Restore from latest backup
Security Breach: Disable affected accounts, check logs
Performance Issues: Check resource usage, scale if needed
Daily: Check service health, review logs
Weekly: Database backup verification
Monthly: Security updates, user account review
Quarterly: Full system backup, performance review
This SOP provides comprehensive procedures for deploying, operating, and maintaining the Advanced Analytics Platform. Follow these procedures to ensure reliable and secure operation of your FDC analytics system.