Add System Monitoring Dashboard with Harbor CI/CD integration
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 5m24s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 10m1s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 5m24s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 10m1s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s
This commit is contained in:
288
README.md
288
README.md
@ -1,3 +1,289 @@
|
||||
# harbor-ci-cd-demo
|
||||
|
||||
Learning Harbor + Gitea Actions CI/CD integration
|
||||
Learning Harbor + Gitea Actions CI/CD integration
|
||||
|
||||
# 🖥️ System Monitoring Dashboard
|
||||
|
||||
A comprehensive Node.js application for real-time system monitoring with a beautiful web dashboard. Built to demonstrate Harbor CI/CD integration with Gitea Actions.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- **🚀 Real-time System Monitoring**: CPU, memory, disk usage, and load averages
|
||||
- **📊 Interactive Dashboard**: Beautiful, responsive web interface with live data
|
||||
- **🔍 Health Checks**: Kubernetes-style readiness and liveness probes
|
||||
- **📡 REST API**: Complete API for system metrics and monitoring data
|
||||
- **🧪 Comprehensive Testing**: Unit tests with coverage reporting
|
||||
- **🔒 Security**: Helmet.js security headers, input validation
|
||||
- **📈 Metrics Collection**: Request tracking, response times, error rates
|
||||
- **🐳 Container Ready**: Optimized Docker configuration
|
||||
- **⚡ Production Ready**: Proper error handling, logging, and monitoring
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Prerequisites
|
||||
- Node.js 18+
|
||||
- Docker (optional)
|
||||
- Git
|
||||
|
||||
### Local Development
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://git.maverickapplications.com/[username]/harbor-ci-cd-demo.git
|
||||
cd harbor-ci-cd-demo
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Start development server
|
||||
npm run dev
|
||||
|
||||
# Open your browser
|
||||
open http://localhost:3000
|
||||
```
|
||||
|
||||
### Using Docker
|
||||
|
||||
```bash
|
||||
# Build and run with Docker
|
||||
docker build -t monitoring-dashboard .
|
||||
docker run -p 3000:3000 monitoring-dashboard
|
||||
|
||||
# Or use Docker Compose
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## 📚 API Documentation
|
||||
|
||||
### System Information
|
||||
- **GET /api/system** - System hardware and OS information
|
||||
- **GET /api/memory** - Memory usage statistics
|
||||
- **GET /api/process** - Node.js process information
|
||||
- **GET /api/metrics** - Application metrics and counters
|
||||
|
||||
### Health Checks
|
||||
- **GET /health** - Basic health status
|
||||
- **GET /health/detailed** - Comprehensive health information
|
||||
- **GET /health/ready** - Readiness probe (Kubernetes compatible)
|
||||
- **GET /health/live** - Liveness probe (Kubernetes compatible)
|
||||
|
||||
### Testing
|
||||
- **GET /api/test** - API connectivity test endpoint
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
npm test
|
||||
|
||||
# Run tests with coverage
|
||||
npm run test:coverage
|
||||
|
||||
# Run tests in watch mode
|
||||
npm run test:watch
|
||||
|
||||
# Run linting
|
||||
npm run lint
|
||||
|
||||
# Fix linting issues
|
||||
npm run lint:fix
|
||||
```
|
||||
|
||||
## 📊 Dashboard Features
|
||||
|
||||
### System Overview
|
||||
- Hostname, platform, and architecture
|
||||
- CPU cores and load averages
|
||||
- Total system memory
|
||||
- System uptime
|
||||
- Node.js version information
|
||||
|
||||
### Memory Monitoring
|
||||
- System memory usage with visual bars
|
||||
- Process heap memory tracking
|
||||
- RSS and external memory statistics
|
||||
- Warning indicators for high usage
|
||||
|
||||
### Health Status
|
||||
- Overall system health indicator
|
||||
- Memory status monitoring
|
||||
- Process uptime tracking
|
||||
- Environment information
|
||||
|
||||
### API Metrics
|
||||
- Request counters by endpoint
|
||||
- Average response times
|
||||
- Service uptime tracking
|
||||
- Real-time performance data
|
||||
|
||||
### Process Information
|
||||
- Process ID and parent process
|
||||
- Working directory
|
||||
- Node.js version details
|
||||
- Environment configuration
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```bash
|
||||
PORT=3000 # Server port (default: 3000)
|
||||
NODE_ENV=production # Environment mode
|
||||
```
|
||||
|
||||
### Docker Environment
|
||||
|
||||
```dockerfile
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
```
|
||||
|
||||
## 🐳 Container Deployment
|
||||
|
||||
### Building the Image
|
||||
|
||||
```bash
|
||||
# Build locally
|
||||
docker build -t monitoring-dashboard:latest .
|
||||
|
||||
# Build for Harbor registry
|
||||
docker build -t registry.maverickapplications.com/infrastructure/monitoring-dashboard:latest .
|
||||
```
|
||||
|
||||
### Running in Production
|
||||
|
||||
```bash
|
||||
# Run with resource limits
|
||||
docker run -d \
|
||||
--name monitoring-dashboard \
|
||||
--memory=512m \
|
||||
--cpus=1 \
|
||||
-p 3000:3000 \
|
||||
-e NODE_ENV=production \
|
||||
--restart=unless-stopped \
|
||||
monitoring-dashboard:latest
|
||||
```
|
||||
|
||||
## 🔄 CI/CD Pipeline
|
||||
|
||||
This application includes a complete CI/CD pipeline with:
|
||||
|
||||
- **🧪 Automated Testing**: Unit tests and coverage reporting
|
||||
- **🔒 Security Scanning**: npm audit and vulnerability checks
|
||||
- **🏗️ Multi-platform Builds**: AMD64 and ARM64 support
|
||||
- **📦 Harbor Integration**: Automatic image building and pushing
|
||||
- **🛡️ Vulnerability Scanning**: Trivy security scanning
|
||||
- **🚀 Automated Deployment**: Environment-based deployment
|
||||
- **📋 SBOM Generation**: Software Bill of Materials
|
||||
|
||||
### Pipeline Stages
|
||||
|
||||
1. **Test & Lint** - Code quality and functionality validation
|
||||
2. **Security Scan** - Dependency vulnerability checking
|
||||
3. **Build & Push** - Multi-platform Docker image creation
|
||||
4. **Image Scan** - Container vulnerability assessment
|
||||
5. **Deploy** - Environment-specific deployment
|
||||
6. **Cleanup** - Resource management
|
||||
|
||||
## 📈 Monitoring & Observability
|
||||
|
||||
### Health Check Endpoints
|
||||
|
||||
```bash
|
||||
# Basic health check
|
||||
curl http://localhost:3000/health
|
||||
|
||||
# Detailed health information
|
||||
curl http://localhost:3000/health/detailed
|
||||
|
||||
# Kubernetes readiness probe
|
||||
curl http://localhost:3000/health/ready
|
||||
|
||||
# Kubernetes liveness probe
|
||||
curl http://localhost:3000/health/live
|
||||
```
|
||||
|
||||
### Metrics Collection
|
||||
|
||||
The application automatically tracks:
|
||||
- HTTP request counters
|
||||
- Response time histograms
|
||||
- Error rate monitoring
|
||||
- Memory usage patterns
|
||||
- System resource utilization
|
||||
|
||||
### Dashboard Access
|
||||
|
||||
- **Main Dashboard**: http://localhost:3000
|
||||
- **API Documentation**: http://localhost:3000/api
|
||||
- **Health Status**: http://localhost:3000/health/detailed
|
||||
|
||||
## 🛠️ Development
|
||||
|
||||
### Project Structure
|
||||
|
||||
```
|
||||
harbor-ci-cd-demo/
|
||||
├── .gitea/workflows/ # CI/CD pipeline configuration
|
||||
├── src/ # Application source code
|
||||
│ ├── routes/ # API route handlers
|
||||
│ ├── middleware/ # Custom middleware
|
||||
│ ├── utils/ # Utility functions
|
||||
│ └── public/ # Frontend assets
|
||||
├── tests/ # Test suites
|
||||
├── Dockerfile # Container configuration
|
||||
├── docker-compose.yml # Local development setup
|
||||
└── package.json # Node.js configuration
|
||||
```
|
||||
|
||||
### Adding New Features
|
||||
|
||||
1. **API Endpoints**: Add routes in `src/routes/`
|
||||
2. **Middleware**: Create middleware in `src/middleware/`
|
||||
3. **Tests**: Add tests in `tests/` directory
|
||||
4. **Frontend**: Update dashboard in `src/public/`
|
||||
|
||||
### Code Style
|
||||
|
||||
- ESLint configuration with recommended rules
|
||||
- Prettier formatting (optional)
|
||||
- Jest testing framework
|
||||
- Security-first approach
|
||||
|
||||
## 🔒 Security Features
|
||||
|
||||
- **Helmet.js**: Security headers and protections
|
||||
- **CORS**: Cross-origin resource sharing control
|
||||
- **Input Validation**: Request data validation
|
||||
- **Error Handling**: Secure error responses
|
||||
- **Health Checks**: System monitoring capabilities
|
||||
- **Container Security**: Non-root user execution
|
||||
|
||||
## 📖 Learn More
|
||||
|
||||
This application demonstrates:
|
||||
- **Modern Node.js Development**: ES6+, async/await, modules
|
||||
- **RESTful API Design**: Resource-based endpoints
|
||||
- **Real-time Monitoring**: Live system metrics
|
||||
- **Container Best Practices**: Multi-stage builds, security
|
||||
- **CI/CD Integration**: Automated testing and deployment
|
||||
- **Production Readiness**: Logging, monitoring, health checks
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Add tests for new functionality
|
||||
4. Ensure all tests pass
|
||||
5. Submit a pull request
|
||||
|
||||
## 📄 License
|
||||
|
||||
MIT License - see LICENSE file for details
|
||||
|
||||
---
|
||||
|
||||
**Built with ❤️ for Harbor CI/CD Demo**
|
||||
|
||||
This application showcases enterprise-grade Node.js development with comprehensive monitoring, testing, and deployment automation.
|
||||
Reference in New Issue
Block a user