#Docker and Custom server.js
9 messages · Page 1 of 1 (latest)
I'm on mobile right now,if you head at next.js repo and click on the examples folder, you lol find a folder called with-docker. It uses standalone mode
Ah custom server.js
You would have to replace the server.js file generated by next.js. you can try a local build with standalone to figure out the path of that file
@high agate Yeah I am able to get my server.js to replace the one that is created, but that doesn't seem to work correctly, it will not start up after that. Both examples work find on their own, but cant seem to get both to work together.
@high agate This is the error that I end up getting
Error: Cannot find module 'app/node_modules/next/dist/server/next.js'. Please verify that the package.json has a valid "main" entry
Interesting, I ll try this tomorrow myself.
Adding this line
COPY --from=builder --chown=nextjs:nodejs /app/server.js ./
worked for me, where server.js is a file I created on the root of my git repo. I added this directly below line 49 here https://github.com/vercel/next.js/blob/a4d907a564e0f73adcaeaa684a00a3faefc5a678/examples/with-docker/Dockerfile#L49
this is causing express not found error