A comprehensive collection of production-ready CI/CD deployment strategies for Next.js applications on VPS servers. Each strategy is battle-tested, secure, and optimized for different use cases.
- Quick Start
- Deployment Strategies Overview
- Strategy Comparison
- Monorepo Support
- Features
- Testing Status
- Roadmap
- Contributing
- License
Choose the deployment strategy that fits your needs:
| Strategy | Best For | Setup Time | Link |
|---|---|---|---|
| Version 1 | Simple apps, fast deployments | β‘ 5 min | v1-do-rsync-pm2 |
| Version 1.5 | Mission-critical apps, instant rollbacks | β‘ 5 min | v1.5-do-rsync-atomic-pm2 |
| Version 2 | Teams preferring Git-based workflows | β‘ 10 min | v2-do-git-pm2 |
Strategy: Build on CI β Rsync artifacts β PM2 zero-downtime reload
- β Fastest deployment (no server-side build)
- β Minimal server footprint (no source code on server)
- β Zero downtime with PM2 cluster mode
- β PR preview deployments support
- β Staging environments support
Use when: You want the fastest, simplest deployment with maximum security.
π Full Documentation
Strategy: Build on CI β Upload to timestamped release β Atomic symlink switch
- β Instant rollbacks (no rebuild needed)
- β Partial failure protection (incomplete uploads don't break site)
- β Release history (keep last 5 releases)
- β Zero downtime deployments
- β PR preview deployments support
- β Staging environments support
Use when: You need instant rollback capability and maximum reliability.
π Full Documentation
Strategy: GitHub Action triggers β Server pulls code β Server builds app
- β Familiar Git workflow
- β No artifact management needed
- β Server-side builds (good for large monorepos)
- β Automatic dependency updates
Use when: You prefer Git-based workflows and have sufficient server resources.
π Full Documentation
| Feature | Version 1 | Version 1.5 | Version 2 |
|---|---|---|---|
| Source Code on Server | β No | β No | |
| SSH Key-Based Auth | β Yes | β Yes | β Yes |
| Restricted Deploy User | β Yes | β Yes | β Yes |
| Minimal Attack Surface | β Highest | β Highest | |
| Secrets Isolation | β Build-time | β Build-time |
Winner: Version 1 & 1.5 (no source code on server)
| Metric | Version 1 | Version 1.5 | Version 2 |
|---|---|---|---|
| Deployment Time | β‘ ~30s | β‘ ~35s | π’ ~2-5 min |
| Build Location | CI/CD | CI/CD | Server |
| Network Transfer | Small artifacts | Small artifacts | Full repo |
| Server CPU Usage | Minimal | Minimal | High (build) |
Winner: Version 1 (fastest), Version 1.5 (slightly slower due to release management)
| Feature | Version 1 | Version 1.5 | Version 2 |
|---|---|---|---|
| Rollback Speed | π’ Rebuild required | β‘ Instant (symlink) | π’ Rebuild required |
| Partial Failure Protection | β High | ||
| Release History | β No | β Yes (5 releases) | β No |
| Zero Downtime | β Yes | β Yes | β Yes |
Winner: Version 1.5 (best reliability and rollback capability)
| Resource | Version 1 | Version 1.5 | Version 2 |
|---|---|---|---|
| Server RAM | Low | Low | High (builds) |
| Server Disk | Low | Medium (releases) | Medium |
| Server CPU | Low | Low | High (builds) |
| CI/CD Minutes | Medium | Medium | Low |
Winner: Version 1 (lowest resource usage)
| Feature | Version 1 | Version 1.5 | Version 2 |
|---|---|---|---|
| PR Preview Deployments | β Yes (single) | β Yes (single) | β No |
| PR Preview (Monorepo) | β No | ||
| Staging Environments | β Yes (single) | β Yes (single) | β No |
| Staging (Monorepo) | β No | ||
| Wildcard SSL Support | β Yes | β Yes | β No |
| Monorepo Support | β Yes | β Yes | β No |
| Git Pull Monorepo | β N/A | β N/A | β Not implemented |
Winner: Version 1 & 1.5 (most features, but monorepo preview/staging missing)
Both Version 1 and Version 1.5 support monorepo deployments with:
- Path-based filtering (only deploy changed apps)
- Multiple apps on one server (isolated ports and PM2 processes)
- Independent deployments per app
- Shared preview infrastructure (one wildcard SSL cert)
π Monorepo Documentation - Version 1
π Monorepo Documentation - Version 1.5
All strategies support:
- β Zero-downtime deployments with PM2
- β Cluster mode for maximum performance
- β SSH key-based authentication
- β Restricted deploy users
- β Nginx reverse proxy configuration
- β SSL certificate setup (Let's Encrypt)
- β Firewall configuration (UFW)
- β Automatic PM2 process management
Version 1 & 1.5 additionally support:
- β PR preview deployments (dynamic ports 8500-8999)
- β Staging environments
- β Wildcard SSL certificates (DigitalOcean & Cloudflare)
- β Dynamic Nginx routing based on hostname
- Single app deployment tested
- Monorepo deployment tested
- PR preview deployment tested
- Staging deployment tested
- Rollback procedure tested
- SSL certificate renewal tested
- PM2 cluster mode verified
- Zero-downtime deployment verified
- Multi-region deployment tested
- Load testing performed
- Single app deployment tested
- Monorepo deployment tested
- PR preview deployment tested
- Staging deployment tested
- Instant rollback tested
- Partial failure recovery tested
- Release cleanup verified
- SSL certificate renewal tested
- Zero-downtime deployment verified
- Multi-region deployment tested
- Load testing performed
- Single app deployment tested
- Monorepo deployment tested
- PR preview deployment tested (
β οΈ Not implemented) - Staging deployment tested (
β οΈ Not implemented) - Build failure recovery tested
- Swap space handling verified
- Large repo performance tested
- SSL certificate renewal tested
- Zero-downtime deployment verified
- Multi-region deployment tested
- Load testing performed
- Multi-app deployment tested
- Path-based filtering verified
- PR preview deployment tested (
β οΈ Not implemented) - Staging deployment tested (
β οΈ Not implemented) - Independent app deployments verified
- Port isolation tested
- Multi-app deployment tested
- Path-based filtering verified
- PR preview deployment tested (
β οΈ Not implemented) - Staging deployment tested (
β οΈ Not implemented) - Independent app deployments verified
- Atomic rollback per app tested
- Port isolation tested
These features are currently missing and should be prioritized:
-
PR Preview for Monorepos
- Version 1 monorepo PR preview workflows
- Version 1.5 monorepo PR preview workflows
- Per-app preview deployments in monorepo
- Preview cleanup automation
-
Staging for Monorepos
- Version 1 monorepo staging workflows
- Version 1.5 monorepo staging workflows
- Per-app staging environments
-
Version 2 (Git Pull) Missing Features
- PR preview deployment support
- Staging deployment support
- Wildcard SSL certificate setup
- Dynamic Nginx routing for previews
-
Git Pull Monorepo Support
- Complete monorepo setup script for Git Pull
- Path-based filtering for Git Pull
- Multiple apps on one server (Git Pull)
- PR preview for Git Pull monorepo
- Staging for Git Pull monorepo
π See TODO.md for detailed tracking of all missing features and implementation details.
-
Docker Support
- Dockerfile templates for Next.js apps
- Docker Compose setup for local development
- Docker-based deployment workflows
- Multi-stage builds optimization
- Container registry integration (Docker Hub, GitHub Container Registry)
-
Kubernetes Support
- Kubernetes manifests (Deployment, Service, Ingress)
- Helm charts for easy deployment
- Kubernetes deployment workflows
- Horizontal Pod Autoscaling (HPA)
- Rolling update strategies
- ConfigMap and Secret management
- Service mesh integration (Istio/Linkerd)
-
Container Orchestration Alternatives
- Docker Swarm setup
- Nomad deployment strategies
- ECS/EKS deployment guides
-
Horizontal Autoscaling
- PM2-based autoscaling configuration
- Load balancer setup (Nginx, HAProxy)
- Multi-server deployment strategies
- Health check endpoints
- Auto-scaling based on CPU/memory metrics
-
Vertical Autoscaling
- Dynamic resource allocation
- Memory optimization strategies
- CPU optimization strategies
-
High Availability
- Multi-region deployment guides
- Database replication strategies
- Session management across servers
- Failover mechanisms
- Disaster recovery procedures
-
PR Preview Deployments - Missing Implementations
- PR preview support for monorepo (Version 1)
- PR preview support for monorepo (Version 1.5)
- PR preview support for Version 2 (Git Pull)
- PR preview cleanup automation (remove old previews)
- PR preview comment updates with deployment status
- Preview deployment health checks
-
Staging Deployments - Missing Implementations
- Staging support for monorepo (Version 1)
- Staging support for monorepo (Version 1.5)
- Staging support for Version 2 (Git Pull)
- Staging environment management
- Staging to production promotion workflow
-
Version 2 (Git Pull) Enhancements
- PR preview deployments for Git Pull strategy
- Staging deployments for Git Pull strategy
- Wildcard SSL support for Git Pull strategy
- Monorepo support for Git Pull strategy
- Path-based filtering for monorepo Git Pull
- Multiple apps on one server (Git Pull)
-
Monorepo Enhancements
- PR preview deployments (Version 1 monorepo)
- PR preview deployments (Version 1.5 monorepo)
- Staging deployments (Version 1 monorepo)
- Staging deployments (Version 1.5 monorepo)
- Cross-app dependency handling
- Shared package deployment strategies
-
Multi-Environment Support
- Development environment setup
- QA environment automation
- Production environment strategies
- Environment-specific configurations
-
Advanced Deployment Strategies
- Blue-Green deployments
- Canary deployments
- Feature flag integration
- A/B testing infrastructure
-
Monitoring & Observability
- Application performance monitoring (APM)
- Log aggregation (ELK, Loki)
- Metrics collection (Prometheus, Grafana)
- Error tracking (Sentry, Rollbar)
- Uptime monitoring
- Real-time alerting
-
Security Enhancements
- Automated security scanning
- Dependency vulnerability checks
- Secrets management (Vault, AWS Secrets Manager)
- WAF (Web Application Firewall) integration
- DDoS protection setup
- Rate limiting strategies
-
AWS
- EC2 deployment guides
- ECS/EKS integration
- Lambda@Edge for edge functions
- CloudFront CDN integration
- Route53 DNS management
-
Google Cloud Platform
- Compute Engine deployment
- GKE (Kubernetes Engine) integration
- Cloud Run serverless option
- Cloud CDN integration
-
Azure
- Azure VM deployment
- AKS (Azure Kubernetes Service) integration
- Azure Container Instances
- Azure CDN integration
-
DigitalOcean
- Droplet deployment optimization
- Kubernetes integration
- App Platform integration
- Spaces (S3-compatible) integration
-
Cloudflare
- Workers deployment
- Pages integration
- Tunnel setup for secure connections
- DDoS protection configuration
-
CDN Integration
- Cloudflare CDN setup
- CloudFront configuration
- Static asset optimization
- Edge caching strategies
-
Caching Strategies
- Redis caching setup
- Memcached integration
- Application-level caching
- Database query caching
-
Database Optimization
- Connection pooling
- Read replicas setup
- Database migration strategies
- Backup and restore procedures
-
Local Development
- Docker Compose for local stack
- Development environment automation
- Hot reload configurations
- Local SSL certificate setup
-
Testing Integration
- Unit test integration
- E2E test automation
- Performance testing
- Security testing automation
-
Documentation
- API documentation generation
- Architecture diagrams
- Troubleshooting guides
- Video tutorials
We welcome contributions! This project aims to provide the best CI/CD strategies for Next.js applications.
Please read our Contributing Guide for detailed information on how to contribute.
- Fork the repository
- Read CONTRIBUTING.md
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following our coding standards
- Test thoroughly using our testing guidelines
- Commit your changes following our commit message format
- Push and create a Pull Request
This project follows a Code of Conduct that all contributors are expected to follow. Please read it before contributing.
We especially welcome contributions in:
- π³ Docker & Kubernetes implementations
- π Monitoring & Observability setups
- π Security enhancements and best practices
- β‘ Performance optimizations
- π Documentation improvements
- π§ͺ Testing and test automation
- π Multi-region deployment strategies
- π Autoscaling configurations
- π Advanced deployment strategies (blue-green, canary)
This project is open source and available under the MIT License.
- PM2 team for the excellent process manager
- Next.js team for the standalone output feature
- Let's Encrypt for free SSL certificates
- All contributors who help improve these deployment strategies
Need Help? Check the individual strategy READMEs or open an issue for support.
Found a Bug? Please report it so we can fix it for everyone!
Have an Idea? We'd love to hear it! Open an issue or start a discussion.