D
Dokployβ€’5mo ago
naz

Next.js project keeps deploying

Hi, When I try to deploy my Next.js app it keeps deploying and I can't see the logs
No description
118 Replies
DJKnaeckebrot
DJKnaeckebrotβ€’5mo ago
You should be able to see logs in the deployments tab. There should be an active deployment from which you can see the logs.
naz
nazOPβ€’5mo ago
Thank you very much, I see them now, I'll try to understand what is happening
Adek
Adekβ€’5mo ago
If you attach the log I'll look over it, maybe can help
naz
nazOPβ€’5mo ago
Thank you, in fact it stops at this step but on Vercel it works fine
No description
naz
nazOPβ€’5mo ago
Adek
Adekβ€’5mo ago
Wait a little bit, atleast should give an error if something is wrong
naz
nazOPβ€’5mo ago
Okey, there is a moment when DokPloy is freezing on the VPS (2vCore, 2Go RAM, 40Go SSD)
naz
nazOPβ€’5mo ago
One hour till now nothing happened it's still on the same point
No description
Henrik
Henrikβ€’5mo ago
I think you're running out of memory unfortunately
naz
nazOPβ€’5mo ago
No description
Henrik
Henrikβ€’5mo ago
That does not give the total for everything that happens Dokploy cannot (currently) give you total used RAM on the system If you SSH into the machine and run journalctl -b 0 --grep "OOM", does it find anything?
naz
nazOPβ€’5mo ago
Thank you, I am actually logging into the VPS give me a sec
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
The thing is that yes, it probably uses a lot of RAM at the begginning of the deployment I've seen that also on Coolify with Next.js projects
Henrik
Henrikβ€’5mo ago
What did journalctl say?
naz
nazOPβ€’5mo ago
No description
Henrik
Henrikβ€’5mo ago
You added a s there
naz
nazOPβ€’5mo ago
otherwise it's a lot of bruteforce from diffrent IPs oh sorry didn't notice
naz
nazOPβ€’5mo ago
No description
Henrik
Henrikβ€’5mo ago
Have you restarted the VPS since you last tried to deploy?
naz
nazOPβ€’5mo ago
Yes but let's try it again
Henrik
Henrikβ€’5mo ago
Aha. No need Change the -b parameter to 1 if you only have restarted once
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
So, I am restarting Didn't know this combo of commands very interesting
Henrik
Henrikβ€’5mo ago
sudo journalctl -b 2 --grep "OOM" I meant the parameter that is tied to -b
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
I am restarting the VPS
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
Didn't know this combo of commands but it's interesting
naz
nazOPβ€’5mo ago
htop still give the same amount of RAM
No description
naz
nazOPβ€’5mo ago
But as I said it's not the first time I face a problem like this with nixpack, Coolify did it too, but on Coolify it rised an error 503 while deploying
naz
nazOPβ€’5mo ago
Still on the same step after reloading
No description
Adek
Adekβ€’5mo ago
For a try can you disable the checking?
Adek
Adekβ€’5mo ago
next.config.js: typescript | Next.js
Next.js reports TypeScript errors by default. Learn to opt-out of this behavior here.
Adek
Adekβ€’5mo ago
debug purpose
naz
nazOPβ€’5mo ago
Yeah let's try this
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
it worked directly
Sang Dang
Sang Dangβ€’5mo ago
I have 2 nextjs projects, both of them will cause my 8GB ram VPS restart if I accidentally build it in Dokploy. This is known issue with Nextjs.
naz
nazOPβ€’5mo ago
Oh but you see that it has builded fine when disabling Type checking
Adek
Adekβ€’5mo ago
The linting part can be added separately if I'm not mistaken
naz
nazOPβ€’5mo ago
it has directly build it and deployed it
No description
Adek
Adekβ€’5mo ago
Can you check htop when building? I'm curious for the stats
Sang Dang
Sang Dangβ€’5mo ago
I'm curious too, sorry for hijack topic πŸ˜›
naz
nazOPβ€’5mo ago
This issue interest me a lot no problem but actually I am not able to take a 8Go RAM VPS only for 2 projects
Sang Dang
Sang Dangβ€’5mo ago
yes, if you could solve this then we should put some notes around Dokplpy Docs, people asking this question A LOT
naz
nazOPβ€’5mo ago
Ah that's nice, as I said I've faced that with Coolify but got no answer like in the DokPloy community let's check the RAM in htop
naz
nazOPβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
after building which is normal imo it has raised for about 100Mo
Sang Dang
Sang Dangβ€’5mo ago
may I ask, where did you run htop?
Adek
Adekβ€’5mo ago
The most interesting part is not giving any errors Can you run npm run build locally? If runs as expected
naz
nazOPβ€’5mo ago
from the VPS, just installed it with apt then htop first time I enjoy deploying my app on PaaS, with Coolify it started to be weired
naz
nazOPβ€’5mo ago
GitHub
GitHub - rapidosaas/job-board-nextjs
Contribute to rapidosaas/job-board-nextjs development by creating an account on GitHub.
naz
nazOPβ€’5mo ago
So, next step is to solve the type checking problem
Adek
Adekβ€’5mo ago
A solution would be to have a dockerfile and use that for build There you can run the lint before building And disable from build Can you share your vps Which provider Maybe I can check this too Later
naz
nazOPβ€’5mo ago
Of course, but I can check this I am here in the DokPloy community, I like the project and I like the used Stack, no needs to do a double job
naz
nazOPβ€’5mo ago
this
No description
naz
nazOPβ€’5mo ago
And I have a second one that I will use to test DokPloy too
naz
nazOPβ€’5mo ago
this one
No description
Adek
Adekβ€’5mo ago
They don't have hourly payment 😦 I'll check with same resources at other provider
naz
nazOPβ€’5mo ago
Yeah but I am using it because it doesn't count the hours
Adek
Adekβ€’5mo ago
Not a problem, I'm a nextjs developer as well so It would be good to resolve the problem before starting to use dokploy
naz
nazOPβ€’5mo ago
Yeah I wonder if we can find an issue for this
Adek
Adekβ€’5mo ago
I mean at hetzner if you use like for 1 hour don't cost your the full month
naz
nazOPβ€’5mo ago
Ah okey, so I am here for that kind of VPS
Adek
Adekβ€’5mo ago
I created a pull request for your repo Merge it And check linting without the config
naz
nazOPβ€’5mo ago
this ?
No description
Adek
Adekβ€’5mo ago
Yes
naz
nazOPβ€’5mo ago
okey let's try it
Adek
Adekβ€’5mo ago
Seems like the build error occured due to sharp, don't know why, I think they added sharp as default in v15
naz
nazOPβ€’5mo ago
Kawa Entertainment
YouTube
[FR][EN] - #livecoding
Ceci est mon message par defaut, si il est affichΓ© c'est que c'est un stream pour streamer jusqu'Γ  ce que je donnes un sens Γ  la vidΓ©os, amusez-vous bien ! This is my default message, if it is displayed it means that it's a stream to just stream until i give the video a sense, Have Fun !
naz
nazOPβ€’5mo ago
unlisted video if you can PR on the develop branch please i don't know if I have created it yet πŸ˜„
Adek
Adekβ€’5mo ago
It will not resolve the issue Seems like you running out of memory
naz
nazOPβ€’5mo ago
so you think it's the memory ? but the docs says that it's enugh 2vCore and 2Go RAM and when we disable the type checking it works perfectly
Adek
Adekβ€’5mo ago
I would say nixpacks cache stuff doing something πŸ™‚ Tomorrow I'll create a dockerfile, let's try it with it
naz
nazOPβ€’5mo ago
okey, let's also keep that package
Adek
Adekβ€’5mo ago
No description
Adek
Adekβ€’5mo ago
naz
nazOPβ€’5mo ago
if you have a change to do now you can PR on the develop branch πŸ˜‰ so finally I have just ignored lint and it worked https://nextjs.org/docs/app/api-reference/config/next-config-js/eslint you can check this video
Adek
Adekβ€’5mo ago
It's not a good practice to disable this step, but if you add npm run lint to your nixpacks config should do the job. Tomorrow I'll have more time to investigate this problem.
Adek
Adekβ€’5mo ago
Introduction | Nixpacks
App source + Nix packages + Docker = Image
Adek
Adekβ€’5mo ago
I'm not too familiar with nixpacks either
naz
nazOPβ€’5mo ago
Thank you very much for your help for the moment I will do liniting locally then, I'll deploy it without Tha question also, is to know if more RAM can fix the problème
Adek
Adekβ€’5mo ago
I will try it tomorrow I got some free time, so I'm looking into this @naz Do you have some time to test?
naz
nazOPβ€’5mo ago
yes of course
Adek
Adekβ€’5mo ago
So I managed to crash as well, this is due to the memory and the nixpacks cache-ing to memory. I found 2 solutions in your case which can help 1. What we did yesterday, disable lint and adding separately here is a file, which you should add to your root folder of your repo nixpacks.toml
[phases.lint]
cmds = ["npm run lint"]
dependsOn = ["install"]

[phases.build]
dependsOn = ["...", "lint"]
[phases.lint]
cmds = ["npm run lint"]
dependsOn = ["install"]

[phases.build]
dependsOn = ["...", "lint"]
and disable the eslint next.config
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
This alone maybe solves the issue 2. Enabling swap space in linux (which is basicly... saving some stuff to the disk and accesing from there) - I'm not an expert, you can find more info in the google, but I followed this tutorial and was like 3-4 min to do and easy to follow just running step by step the commands and changing a file https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04
How To Add Swap Space on Ubuntu 22.04 | DigitalOcean
One way to guard against out-of-memory errors in applications is to add some swap space to your server. In this guide, we will cover how to add a swap file t…
Adek
Adekβ€’5mo ago
I tried with 4GB and everything was ok
naz
nazOPβ€’5mo ago
Both solutions interest me, so to optimise the VPS we should ignore eslint in the VPS but not in local as it's a double use
Adek
Adekβ€’5mo ago
Nope, you use it in vps as well
naz
nazOPβ€’5mo ago
Then the second solution to have a 4Go RAM VPS is okey
Adek
Adekβ€’5mo ago
Because it's a safety stuff
naz
nazOPβ€’5mo ago
ah okey I understand
Adek
Adekβ€’5mo ago
So basicly you lint first and after run the build
Adek
Adekβ€’5mo ago
No description
naz
nazOPβ€’5mo ago
why linting in production is important ?
Adek
Adekβ€’5mo ago
The problem was that the build step used lint and validity type check at asme time And used too much memory Because it's safer to run before a deployment is out(maybe you forget linting) For an example you change a component which has 3 props, and you add one more You use this component in 4 places in your app Eslint will tell you if you forget to update in a location So let's say you added that prop in 3 places but forget to add in the last place And it will detect it so you can fix it Better to have it, than not πŸ™‚
Adek
Adekβ€’5mo ago
Find and fix problems in your JavaScript code - ESLint - Pluggable ...
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
naz
nazOPβ€’5mo ago
So the solution is to add nixpacks.toml
[phases.lint]
cmds = ["npm run lint"]
dependsOn = ["install"]

[phases.build]
dependsOn = ["...", "lint"]
[phases.lint]
cmds = ["npm run lint"]
dependsOn = ["install"]

[phases.build]
dependsOn = ["...", "lint"]
Adek
Adekβ€’5mo ago
I'm not a senior dev so you, don't count in me πŸ™‚ I would do both of the solutions
naz
nazOPβ€’5mo ago
Okey, am not a senior dev too πŸ˜„
Adek
Adekβ€’5mo ago
Both of them helps with memory issues I tried only with swap and worked with that as well (Using your repo)
naz
nazOPβ€’5mo ago
So the solution to deploy a Next.js app is : - add nixkpacks.toml - disable eslint - activate memory swap or buy a 2vCore and 4Go RAM VPS
Adek
Adekβ€’5mo ago
Yes, I would do all of them πŸ˜‰
naz
nazOPβ€’5mo ago
Nice Actually just disabling eslint works fine for me so I go with this solution at a first step, then I will see the other steps I'll do the eslint checks locally with npm run lint Thank you very much for the help
Adek
Adekβ€’5mo ago
Anytime! @Sang Dang Maybe this can help you too.
Sang Dang
Sang Dangβ€’5mo ago
thank you, I disabled the eslint on dokploy building and run it on github actions instead, it reduced down to 5mins build πŸ˜„ which is pretty good in our case it used to 20 mins ha ha
naz
nazOPβ€’5mo ago
How did you disabled eslint on DokPloy ?
Sang Dang
Sang Dangβ€’5mo ago
ah my bad, I disabled the eslint in the build
naz
nazOPβ€’5mo ago
ah okey 20 min even with 8Go RAM ?
Sang Dang
Sang Dangβ€’5mo ago
no 20min with github actions
naz
nazOPβ€’5mo ago
ok, I understand
Adek
Adekβ€’5mo ago
Which package manager do you use?
Sang Dang
Sang Dangβ€’5mo ago
but I think I will try to move the build back to dokploy after this currently it's pnpm
Adek
Adekβ€’5mo ago
Did you try moving from nixpacks to Dockerfile?
Sang Dang
Sang Dangβ€’5mo ago
I did. I did not know the eslint caused the issue. So I had to build into dockerfile in github actions, and use it to deplpy on dokploy
Adek
Adekβ€’5mo ago
Let me know when you try moving back to dokploy building because I would like to investigate the problem if it's still there.
Sang Dang
Sang Dangβ€’5mo ago
sure I will, but it would not happen in near future, it is production app and we are quite out of resources to test

Did you find this page helpful?