Next.js Discord

Discord Forum

Issue with Next.js Build

Answered
Teddy Roosevelt Terrier posted this in #help-forum
Open in Discord
Teddy Roosevelt TerrierOP
I'm using @nx/next and run 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 ./next


Then, 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-id


I'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

COPY dist/apps/vhg/next ./next

in my Dockerfile.
View full answer

1 Reply

Teddy Roosevelt TerrierOP
Nevermind. I accidentally left out the "." in front of "next" in my

COPY dist/apps/vhg/next ./next

in my Dockerfile.
Answer