Issue with Next.js Build
Answered
Teddy Roosevelt Terrier posted this in #help-forum
Teddy Roosevelt TerrierOP
I'm using @nx/next and run
My Dockerfile then copies these folders over to my container environment:
Then, at the end of the Dockerfile, I run
to start the server.
However, when this runs, I get the following error:
I'm not sure why my build can't be found in
in my local directory after running the
nx build [my-app] to build the /dist/apps/[my-app]/.next and /dist/apps/[my-app]/public directories locally.My Dockerfile then copies these folders over to my container environment:
WORKDIR /usr/src/app
...
COPY dist/apps/vhg/public ./public
COPY dist/apps/vhg/.next ./nextThen, at the end of the Dockerfile, I run
CMD ["dumb-init", "npm", "start"]to start the server.
However, when this runs, I get the following error:
Error: Could not find a production build in the '/usr/src/app/.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-idI'm not sure why my build can't be found in
/usr/src/app/.next I see dist/apps/vhg/public
dist/apps/vhg/in my local directory after running the
nx build [my-project command. Doesn't that commend essentially run next build' as suggested to do in the error message mentioned above?Answered by Teddy Roosevelt Terrier
Nevermind. I accidentally left out the "." in front of "next" in my
in my Dockerfile.
COPY dist/apps/vhg/next ./nextin my Dockerfile.
1 Reply
Teddy Roosevelt TerrierOP
Nevermind. I accidentally left out the "." in front of "next" in my
in my Dockerfile.
COPY dist/apps/vhg/next ./nextin my Dockerfile.
Answer