A no-downtime multi-tenant Next.js self-host deployment manager
Port-Au-Next allows you to self-host multiple Next.js applications using Docker containers. It uses blue/green deployments to update your apps without any downtime - when a new version is ready, traffic switches over seamlessly. You maintain full control of your infrastructure without being locked into cloud platforms.
Whether you're deploying to a VPS, cloud server, or hardware in your own environment, Port-Au-Next provides an elegant solution for managing your Next.js application fleet with secure user authentication and powerful preview branch capabilities.
- Blue/Green Deployments: Seamless deployments with zero downtime using a true blue/green strategy
- Multi-Tenancy: Host multiple Next.js applications on a single server
- Domain Management: Connect multiple domains/subdomains to specific applications and branches
- Preview Branches: Deploy and test feature branches with isolated environments and custom subdomains
- User Authentication: Secure admin interface with user management and authentication
- GitHub Actions Integration: Automatically deploy when pushing to configured branches
- Health Checks: Intelligent service switching only when new deployments are verified healthy
- Environment Isolation: Each app, branch, or preview deployment can have its own environment variables
- Customizable Build Process: Use the default optimized Dockerfile or create your own
- Shared Infrastructure: PostgreSQL, Redis, and imgproxy services available to all applications
- Web-Based Management UI: Monitor and control your deployments through an intuitive interface
Port-Au-Next uses a Docker-based microservices architecture with the following components:
- Nginx Reverse Proxy: Routes traffic to the correct application containers and preview branch deployments
- Deployment Manager: Web UI and API for managing applications and deployments, with secure authentication
- Authentication Layer: Handles user authentication and session management
- Preview Branch Manager: Manages isolated preview environments for feature branches
- Shared Services: PostgreSQL, Redis, and imgproxy available to all applications
- Application Containers: Isolated containers for each application version and preview branch
- Docker and Docker Compose
- Git
- SSH key for GitHub authentication (for automatic deployments)
- Clone the repository:
git clone https://github.com/cfpg/port-au-next.git
cd port-au-next- Create a
.envfile with required variables, you can copy.env.exampleas a starter:
# Deployment Manager
DEPLOYMENT_MANAGER_HOST=domain.to.access.manager.com
DEPLOYMENT_MANAGER_AUTH_EMAIL=changeto@yourdomain.com
DEPLOYMENT_MANAGER_AUTH_PASSWORD=changeme098
BETTER_AUTH_SECRET=changeme567
# Shared Postgres DB superuser credentials
POSTGRES_USER=portaunext
POSTGRES_PASSWORD=changeme123
POSTGRES_DB=portaunext
# Image Optimization
IMGPROXY_HOST=cdn.yourdomain.com
# Minio Configuration
MINIO_HOST=storage.yourdomain.com
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
# Optinal: Used for cache busting
CLOUDFLARE_API_KEY=your_cloudflare_api_token
CLOUDFLARE_API_EMAIL=your_cloudflare_api_email- Launch the system:
docker compose up --build -d- Access the deployment manager UI at
http://localhost:80or using theDEPLOYMENT_MANAGER_HOSTyou configured in the.envfile and log in with the configured admin credentials
Port-Au-Next implements a blue/green deployment strategy:
- Preparation: A new deployment is initiated via the UI or GitHub webhook
- Building: The latest code is pulled and built into a new Docker image
- Launching: A new container is started with the updated code and assigned a version
- Health Check: The new container is verified as healthy
- Switching: Nginx configuration is updated to route traffic to the new container
- Cleanup: The previous container is gracefully terminated
This approach ensures your applications remain available throughout the entire deployment process.
Preview branches allow you to deploy and test feature branches in isolated environments before merging to production:
- Setup: Enable preview branches for an application and configure a preview domain:
- For example, use
preview.yourdomain.comand setup a wildcard CNAME entry in your DNS server pointing to your server:*.preview.yourdomain.com IN CNAME yourdomain.com
- For example, use
- Deployment: Deploy any branch to get an isolated environment with:
- Unique subdomain (e.g.,
feature-branch.preview.yourdomain.com) - Isolated database
- Global preview and branch-specific environment variables, allows you to point your preview environments to DEV services and use test new variables per branch
- Unique subdomain (e.g.,
- Testing: Test your changes in a production-like environment
- Cleanup: Automatically or manually clean up preview environments when no longer needed
- Preview branches can be enabled/disabled per application
- Each preview deployment gets its own database and environment
- Environment variables can be set specifically for preview deployments
- Automatic cleanup options available for merged/deleted branches
- From the deployment manager UI, create a new application
- Provide the Git repository URL and branch to deploy
- Configure domain settings and environment variables
- Initiate the first deployment
- Navigate to your application's settings
- Configure a preview domain (e.g.,
*.preview.yourdomain.com) - Enable the preview branches feature
- Configure default preview environment variables (optional)
- Access the user management section from settings
- Add new users with appropriate permissions
- Manage user access and passwords
- Configure authentication settings
Port-Au-Next will use a repository's Dockerfile if present. Otherwise, it creates an optimized Dockerfile configured for Next.js applications with:
- Multi-stage build process
- Proper caching of dependencies
- Production-optimized settings
- Non-root user execution
Environment variables can be configured:
- Per application (base configuration)
- Per branch within an application (branch-specific overrides)
- Per preview deployment (preview-specific settings)
This flexibility enables managing multiple environments (development, staging, production) within the same Port-Au-Next instance.
Port-Au-Next exposes a REST API for programmatic control. Here are key endpoints:
POST /api/:app/deploy: Trigger a deployment for an applicationGET /api/apps: List all registered applicationsGET /api/apps/:name/deployments: List deployments for a specific applicationGET /api/apps/:name/logs/:deploymentId: Fetch logs for a specific deployment
POST /api/apps/:appId/preview-branches: Enable preview branches for an appPOST /api/apps/:appId/preview-branches/:branch/deploy: Deploy a preview branchDELETE /api/apps/:appId/preview-branches/:branch: Delete a preview branchGET /api/apps/:appId/preview-branches: List active preview branches
POST /api/auth/login: Authenticate user and get sessionPOST /api/auth/logout: End current sessionPOST /api/auth/password: Change user passwordGET /api/auth/session: Get current session info
The deployment manager provides:
- Deployment status tracking
- Container logs
- Health metrics
- Preview branch status monitoring
- Rollback capability for failed deployments
- All services run in an isolated Docker network
- SSH keys for repository access are mounted read-only
- Database credentials are managed securely
- Docker socket access is restricted to the deployment manager
- Secure session management for authenticated users
- Preview branch environments are fully isolated
- Environment variables are securely stored and managed
- Regular security updates available through Docker images
Port-Au-Next is released under the MIT License. See LICENSE for details.
Port-Au-Next: Deploy Next.js applications on your terms
