Github CICD NextJS on Plesk
On Plesk
- Create domain.
- Select NodeJS
- Select Temporary domain name
- Create SSL
- Domaindashboard > Get Started > NodeJS > Enable & restart
- Add Deploy keys in Git
- Restart app (See Node settings)
- Check Application Root & Document Root:
/httpdocs
- Node Settings:
npm install & npm build
- A .next-folder is created, change
- document root to
/httpdocs/.next/static
- Application startup file to
node_modules/.bin/next
- document root to
- Check node_modules/.bin/next
program.command("dev", {
isDefault: true
})
program.command("start")
before
remove {isDefault:true}
and paste it in program.command("start")
program.command("dev")
program.command("start", {
isDefault: true
})
after
- Go to git setting and copy webhook, paste in github.
- Hosting Settings > SSH access > /bin/bash
In git settings paste folowing deploy actions
rm -rf tmp
(PATH=/opt/plesk/node/22/bin:$PATH; npm install && npm run build &> npm-install.log &)
mkdir tmp
touch tmp/restart.txt
Trouble shooting
If it doesnt work, check for errors; Node settings "+ NPM INSTALL" & "RUN SCRIPT" > Build.
Eslint Error
Change .eslintrc.json;
{
"extends": ["next"]
}
.eslintrc.json