nextjs-deployment
Provides comprehensive patterns for deploying Next.js applications to production. Use when configuring Docker containers, setting up GitHub Actions CI/CD pipelines, managing environment variables, implementing preview deployments, or setting up monitoring and logging for Next.js applications. Covers
By giuseppe-trisciuoglio · 2,828 installs
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment
Source repository · Upstream listing
Next.js Deployment
Deploy Next.js applications to production with Docker, CI/CD pipelines, and comprehensive monitoring.
Overview
This skill provides patterns and code examples for deploying Next.js applications to production environments. It covers containerization with Docker, CI/CD automation with GitHub Actions, environment configuration, health checks, and production monitoring. Use standalone output mode for container deployments, multi stage Docker builds for optimized images, and OpenTelemetry for observability.
When to Use
Activate when user requests involve:
"Deploy Next.js", "Dockerize Next.js", "containerize"
"GitHub Actions", "CI/CD pipeline", "automated deployment"
"Environment variables", "runtime config", "NEXT PUBLIC"
"Preview deployment", "staging environment"
"Monitoring", "OpenTelemetry", "tracing", "logging"
"Health checks", "readiness", "liveness"
"Production build", "standalone output"
"Server Actions encryption key", "NEXT SERVER ACTIONS ENCRYPTION KEY"
Quick Reference
Output Modes
Mode Use Case Command
standalone Docker/container deployment output: 'standalone'
export Static site (no server) output: 'export'
(default) Node.js server deployment next start
Environment Variable Types
Prefix Availability Use Case
NEXT PUBLIC Build time + Browser Public API keys, feature flags
(no prefix) Server only Database URLs, secrets
Runtime Server only Different values per environment
Key Files
File Purpose
Dockerfile Multi stage container build
.github/workflows/deploy.yml CI/CD pipeline
next.config.ts Build configuration
instrumentation.ts OpenTelemetry setup
src/app/api/health/route.ts Health check endpoint
Instructions
1. Configure Standalone Output
2. Create Dockerfile
See [references/docker patterns.md](references/docker patterns.md) for complete multi stage builds, multi arch support, and optimization.
3. Set Up GitHub Actions
See [references/github actions.md](references/github actions.md) for complete workflows with testing, security scanning, and deployment strategies.
4. Configure Environment Variables
5. Implement Health Checks
6. Set Up Monitoring
See [references/monitoring.md](references/monitoring.md) for OpenTelemetry configuration, logging, alerting, and dashboards.
7. Handle Server Actions Encryption
CRITICAL : Generate and set consistent encryption key for multi server deployments:
Without this key, Server Actions fail with "Failed to find Server Action" errors in multi server deployments.
Best Practices
Docker : Use multi stage builds, enable standalone output, set non root user, include health checks
Security : Never commit .env.local , use NEXT PUBLIC only for public values, set NEXT SERVER ACTIONS ENCRYPTION KEY
Performance : Use output: 'standalone' , enable CDN for static assets, use next/image
Environment : Use same Docker image across environments, inject runtime config via env vars
Examples
Constraints and Warnings
Constraints
Standalone output requires Node.js 18+
Server Actions encryption key must be consistent across all instances
Runtime environment variables only work with output: 'standalone'
OpenTelemetry requires instrumentation.ts at project root
Warnings
Never use NEXT PUBLIC prefix for sensitive values
Always set NEXT SERVER ACTIONS ENCRYPTION KEY for multi server deployments
Without health checks, orchestrators may send traffic to unhealthy instances
Runtime env vars don't work with static export ( output: 'export' )
References
[references/docker patterns.md](references/docker patterns.md) Advanced Docker configurations, multi arch builds, optimization
[references/github actions.md](references/github actions.md) Complete CI/CD workflows, testing, security scanning
[references/monitoring.md](references/monitoring.md) OpenTelemetry, logging, alerting, dashboards
[references/deployment platforms.md](references/deployment platforms.md) Platform specific guides (Vercel, AWS, GCP, Azure)