UNPKG

codewithgarry

Version:

Girish Sharma's NPX business card - DevOps Engineer & Cloud Architect - Connect with me directly via terminal!

212 lines (160 loc) 3.77 kB
# 🚀 CodeWithGarry NPX Card - Production Deployment Guide ## Quick Start ### Development ```bash # Install dependencies npm install # Run in development mode npm run dev # Run tests npm test ``` ### Production Deployment #### Option 1: Docker (Recommended) ```bash # Build and run with Docker npm run docker:build npm run docker:run # Or use Docker Compose npm run docker:compose ``` #### Option 2: Direct Node.js ```bash # Install production dependencies npm ci --only=production # Run in production mode npm run prod ``` ## Environment Configuration Copy `.env.example` to `.env` and configure: ```bash cp .env.example .env # Edit .env with your settings ``` ### Required Environment Variables - `NODE_ENV`: Environment (development/production) - `PORT`: Application port (default: 3000) - `GITHUB_USERNAME`: GitHub username for stats - `SESSION_SECRET`: Secret for session management ## Production Features ### 🔒 Security - CSP headers configured - Rate limiting enabled - Input validation - Non-root user in Docker - Security scanning in CI/CD ### 📊 Monitoring - Health checks - Prometheus metrics - Error tracking - Performance monitoring ### 🚀 Performance - Gzip compression - Static asset caching - Optimized Docker images - Bundle size monitoring ### 🔄 CI/CD - Automated testing - Security scanning - Multi-stage builds - Automated deployment ## Deployment Options ### Heroku ```bash # Create Heroku app heroku create your-app-name # Set environment variables heroku config:set NODE_ENV=production heroku config:set SESSION_SECRET=your-secret # Deploy git push heroku main ``` ### Kubernetes ```bash # Build and push image docker build -t your-registry/codewithgarry-card . docker push your-registry/codewithgarry-card # Deploy to Kubernetes kubectl apply -f k8s/ ``` ### DigitalOcean App Platform ```bash # Use the docker-compose.yml or Dockerfile # Configure environment variables in DO dashboard ``` ### AWS ECS/Fargate ```bash # Push to ECR aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin your-account.dkr.ecr.us-east-1.amazonaws.com docker build -t codewithgarry-card . docker tag codewithgarry-card:latest your-account.dkr.ecr.us-east-1.amazonaws.com/codewithgarry-card:latest docker push your-account.dkr.ecr.us-east-1.amazonaws.com/codewithgarry-card:latest ``` ## Monitoring & Maintenance ### Health Checks - **HTTP**: `GET /health` - **Docker**: Built-in healthcheck - **K8s**: Liveness and readiness probes ### Logs ```bash # Docker logs docker logs codewithgarry-card # Production logs npm run logs ``` ### Metrics - Prometheus: `http://localhost:9090` - Application metrics: `/metrics` ## Troubleshooting ### Common Issues **NPM Installation Fails** ```bash # Clear cache and reinstall npm run clean ``` **Docker Build Fails** ```bash # Check Docker daemon docker system info # Build with verbose output docker build --no-cache -t codewithgarry-card . ``` **Port Already in Use** ```bash # Change port in environment export PORT=3001 npm start ``` ### Performance Issues ```bash # Check bundle size npm run bundle-size # Profile memory usage node --inspect index.js ``` ## Security ### Security Scanning ```bash # Audit dependencies npm audit # Security scan npm run security ``` ### Updates ```bash # Check for updates npm outdated # Update dependencies npm update ``` ## Support - 📧 Email: devops.girishsharma@gmail.com - 🐙 GitHub: [Issues](https://github.com/codewithgarry/npx-card/issues) - 💼 LinkedIn: [CodeWithGarry](https://linkedin.com/in/codewithgarry) ## Contributing 1. Fork the repository 2. Create feature branch 3. Run tests: `npm test` 4. Submit pull request ## License MIT License - see LICENSE file for details.