@philiprehberger/next-deploy
v0.1.9
Published
Release-based SSH deployment for Next.js apps with symlinks, dependency caching, and PM2 management
Downloads
1,208
Readme
@philiprehberger/next-deploy
Release-based SSH deployment for Next.js apps with symlinks, dependency caching, and PM2 management
Installation
npm install @philiprehberger/next-deployUsage
Server Structure
/var/www/myapp/
├── releases/
│ ├── 20251212112502/
│ ├── 20251213093015/
│ └── ..
├── current -> releases/20251213093015/
└── shared/
└── .envCLI
npx next-deploy
npx next-deploy --skip-build
npx next-deploy --fresh
npx next-deploy --dry-runConfiguration
Option 1: Config file (deploy.config.js)
module.exports = {
server: {
host: 'example.com',
username: 'deploy',
privateKeyPath: '~/.ssh/id_rsa',
},
paths: {
basePath: '/var/www/myapp',
},
pm2Process: 'myapp',
filesToTransfer: ['.next', 'public', 'package.json', 'package-lock.json', 'next.config.mjs'],
releasesToKeep: 5,
};Option 2: Environment variables
SERVER_HOST=example.com
SERVER_USERNAME=deploy
SERVER_PRIVATE_KEY=~/.ssh/id_rsa
SERVER_BASE_PATH=/var/www/myapp
SERVER_PM2_PROCESS=myapp
RELEASES_TO_KEEP=5Programmatic API
import { deploy, loadConfigFromEnv } from '@philiprehberger/next-deploy';
const config = loadConfigFromEnv({
hooks: {
postDeploy: (releaseName) => {
console.log(`Deployed ${releaseName}!`);
},
},
});
const result = await deploy(config, { skipBuild: false });
console.log(result.success ? 'Done!' : `Failed: ${result.error}`);API
| Method | Description |
|--------|-------------|
| deploy(config, options?) | Run a full deployment with the given config and options |
| loadConfig(projectRoot) | Load deploy config from a config file in the project root |
| loadConfigFromEnv(overrides?) | Load deploy config from environment variables with optional overrides |
Development
npm install
npm run build
npm testSupport
If you find this project useful:
