Next.js Discord

Discord Forum

Deploy Custom Server.js

Answered
Japanese flying squid posted this in #help-forum
Open in Discord
Japanese flying squidOP
I want to deploy my Next.js app, which is using custom server.js for socket.io. Which service would you recommend to be very simple to deploy? ( I am using Render now, any other )
Answered by B33fb0n3
This tutorial was used: https://www.youtube.com/watch?v=sIVL4JMqRfc

- First setup Cloudflare correctly. Your domain nameserver should point to Cloudflare.
- Inside DNS setup an A record at root level to your VPS
- If you don't have an VPS yet, I recommend netcup as hoster: https://www.netcup.com/?ref=164929
- Then use the attached deployment script and exchanged all env variables and variables in general. Also exchanged everything that is something with b33f.de (named: deploy.sh so it can be executed later on your VPS)
- Upload it on your VPS
- Grant permissions to be able to execute the deploy.sh script
- Execute that file. Wait until your whole repo is there.
- Add the attached Dockerfile to the APP_DIR folder. Exchange to the NPM that you are using. This dockerfile is for pnpm (named: Dockerfile)
- Add the attached docker-compose file as well (named: docker-compose.yml) to the APP_DIR folder. Remove the curl if not needed.
- Run the deploy script again. Hope that there are no errors.

If there are errors while running the deploy.sh script:
- Check the service that runs into an issue. Maybe you misconfigured it.
- If there is something with "no permission", execute it with sudo in front of the command
View full answer

7 Replies

Japanese flying squidOP
I don't want to use VPS and do all the stuff by myself
@B33fb0n3 why don't you want to use a VPS?
Japanese flying squidOP
It's hard to manage this domains, make it running automatically after maybe shutdown or something? no?
@Japanese flying squid It's hard to manage this domains, make it running automatically after maybe shutdown or something? no?
not really if you have cloudflare (it's free), a domain and a deployment script. I can share you the deployment script. But you need to bought a domain
Japanese flying squidOP
Can you message me in DM? I will explain my situation better
Make sure to stay inside this thread, so others have the solution as well
This tutorial was used: https://www.youtube.com/watch?v=sIVL4JMqRfc

- First setup Cloudflare correctly. Your domain nameserver should point to Cloudflare.
- Inside DNS setup an A record at root level to your VPS
- If you don't have an VPS yet, I recommend netcup as hoster: https://www.netcup.com/?ref=164929
- Then use the attached deployment script and exchanged all env variables and variables in general. Also exchanged everything that is something with b33f.de (named: deploy.sh so it can be executed later on your VPS)
- Upload it on your VPS
- Grant permissions to be able to execute the deploy.sh script
- Execute that file. Wait until your whole repo is there.
- Add the attached Dockerfile to the APP_DIR folder. Exchange to the NPM that you are using. This dockerfile is for pnpm (named: Dockerfile)
- Add the attached docker-compose file as well (named: docker-compose.yml) to the APP_DIR folder. Remove the curl if not needed.
- Run the deploy script again. Hope that there are no errors.

If there are errors while running the deploy.sh script:
- Check the service that runs into an issue. Maybe you misconfigured it.
- If there is something with "no permission", execute it with sudo in front of the command
Answer