Next.js Discord

Discord Forum

devcontainer

Answered
Transvaal lion posted this in #help-forum
Open in Discord
Avatar
Transvaal lionOP
i want to make webapp with nextjs, i have a vps with docker installed in it, and i don't want to install node in the server, can i do that using Dockerfile, docker-compose.yml and package.json?

25 Replies

Answer
Avatar
But yes. You only need Docker installed, no need to install nodejs
Avatar
Transvaal lionOP
thanks for reply, can i just use this https://github.com/vercel/next.js/blob/canary/examples/with-docker-compose/compose.dev.yaml docker compose without Dockerfile? i don't see the docker file inside this
Avatar
Transvaal lionOP
ohh thanks i was blind
thank you very much
Avatar
Transvaal lionOP
i did this, and it works, but too much files, i want a very basic and simple setup with only Dockerfile, docker-compose and package.json, is there is something simple like that?
Avatar
i dont have an example for you but it is doable. well you need either another Dockerfile or another docker-compose specifically for development (if you want to run dev mode inside Docker too), but it is doable.
Avatar
Transvaal lionOP
i'm tryed to do it 3 days now without success, ai make ms crazy
Avatar
uh... learn how to write a dockerfile and how to write a docker-compose.yml file, then you should be able to do it
Avatar
Transvaal lionOP
but now finaly i get it 😄
thank you very much
my problem was not with docker compose as i was familiar with it
the problem was with package.json, that's what drives me crazy
but now after your help with th compose file in the git, i want able to make very basic file 😄
Avatar
oh, just stick with the default package.json, there isnt anything you need to do there to make it work
Avatar
Transvaal lionOP
thnak you very very very much
Avatar
package.json is not part of the deployment workflow
Avatar
Transvaal lionOP
yes but it's mandatory? i have to specify that in Dockerfile,
Avatar
well yeah, package.json is where you declare your dependencies so you must have it
optionally you should have the lockfile as well (package-lock.json, yarn.lock, pnpm-lock.yaml or bun.lockb depending on which package manager you use)
Avatar
Transvaal lionOP
yes, only package-lock.json is optional
Avatar
package.json is not needed for docker but needed for npm install which is what you absolutely need to run during the docker image build
Avatar
Transvaal lionOP
correct, during the build i need only package.json, and package-lock will be generate with npm install
Avatar
the lockfile is optional but still highly recommended because without it you could have different dependency versions in your vps which could cause different behaviours https://stackoverflow.com/a/66074027