monorepo .next folder not included in docker image

ProjectId: a2ab11df-7f4e-4ea5-8c53-1f345f0fc425 Using Nixpack and turborepo. Build runs fine, but when it runs the start command it logs out
Could not find a production build in the '/app/apps/client/.next' directory.
Could not find a production build in the '/app/apps/client/.next' directory.
I can tell it to build on the start command again, but half the time that will run into this error:
next build
internal:build: info - Linting and checking validity of types...
internal:build: events.js:377
internal:build: throw er; // Unhandled 'error' event
internal:build: ^
internal:build:
internal:build: Error: spawn /nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node EAGAIN
internal:build: at Process.ChildProcess._handle.onexit (internal/child_process.js:277:19)
internal:build: at onErrorNT (internal/child_process.js:472:16)
internal:build: at processTicksAndRejections (internal/process/task_queues.js:82:21)
internal:build: Emitted 'error' event on ChildProcess instance at:
internal:build: at Process.ChildProcess._handle.onexit (internal/child_process.js:283:12)
internal:build: at onErrorNT (internal/child_process.js:472:16)
internal:build: at processTicksAndRejections (internal/process/task_queues.js:82:21) {
internal:build: errno: -11,
internal:build: code: 'EAGAIN',
internal:build: syscall: 'spawn /nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node',
internal:build: path: '/nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node',
internal:build: spawnargs: [
internal:build: '/app/node_modules/next/dist/compiled/jest-worker/processChild.js'
internal:build: ]
internal:build: }
internal:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
next build
internal:build: info - Linting and checking validity of types...
internal:build: events.js:377
internal:build: throw er; // Unhandled 'error' event
internal:build: ^
internal:build:
internal:build: Error: spawn /nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node EAGAIN
internal:build: at Process.ChildProcess._handle.onexit (internal/child_process.js:277:19)
internal:build: at onErrorNT (internal/child_process.js:472:16)
internal:build: at processTicksAndRejections (internal/process/task_queues.js:82:21)
internal:build: Emitted 'error' event on ChildProcess instance at:
internal:build: at Process.ChildProcess._handle.onexit (internal/child_process.js:283:12)
internal:build: at onErrorNT (internal/child_process.js:472:16)
internal:build: at processTicksAndRejections (internal/process/task_queues.js:82:21) {
internal:build: errno: -11,
internal:build: code: 'EAGAIN',
internal:build: syscall: 'spawn /nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node',
internal:build: path: '/nix/store/6jibg9l09nvjf96f21cf16fmk4qhsfw1-nodejs-14.20.0/bin/node',
internal:build: spawnargs: [
internal:build: '/app/node_modules/next/dist/compiled/jest-worker/processChild.js'
internal:build: ]
internal:build: }
internal:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
25 Replies
JustJake
JustJake•2y ago
Is this by chance running off two identical copies of the same codebase?
Tanner Scadden
Tanner Scadden•2y ago
I have 4 apps running from this code base. 3 are based on nextjs, one is my api. 2/3 of the nextjs apps always fail. The other one will succeed.
JustJake
JustJake•2y ago
Right but they all build on the same push right?
Tanner Scadden
Tanner Scadden•2y ago
yes Do I need to split them up into more projects inside of railway?
JustJake
JustJake•2y ago
I'm unsure but the guy who built a lot of that is back from PTO tomorrow* Suspect it's a weird concurrency thing?
Tanner Scadden
Tanner Scadden•2y ago
Okay. I'll wait until tomorrow. Thanks for the update 🙂 Could be. I didn't think about it before but it is weird that only 1/3 of the nextjs apps will build correctly, and it's random which one will.
JustJake
JustJake•2y ago
Oh hmm These are on start Why is your application building on start?
Tanner Scadden
Tanner Scadden•2y ago
It was a workaround that was working for getting around the docker image not including the .next folder
JustJake
JustJake•2y ago
What's the error for this one? ^^ Cause right now you're building on start and that's no bueno (Regardless of if we fix your issue)
Tanner Scadden
Tanner Scadden•2y ago
Ya it was a fix to get it deploying, but that workaround isn't working anymore. Site isn't being used by clients yet so I'm not too worried.
JustJake
JustJake•2y ago
Right. What was the error before the workaround. Is what I'm wondering So we can fix that
Tanner Scadden
Tanner Scadden•2y ago
The docker image that gets built is ignoring .next folders in monorepos. Build stage runs fine, start errors out with directory not found.
Could not find a production build in the '/app/apps/client/.next' directory.
Could not find a production build in the '/app/apps/client/.next' directory.
JustJake
JustJake•2y ago
Turbo monorepo right? I think that the .next file goes to the root :/ Err, or maybe not? Any shot you've got a codebase I could test on? Totally fine if not
Tanner Scadden
Tanner Scadden•2y ago
It goes to the root of the project it is built in.
JustJake
JustJake•2y ago
Right then whys it looking in app/apps/client/.next Instead of .next in the root :/ Which is probably where that is
Tanner Scadden
Tanner Scadden•2y ago
Let me change the start command and see if that fixes it.
Could not find a production build in the '/app/.next' directory.
Could not find a production build in the '/app/.next' directory.
Pretty sure it stays scoped to the folder it was built in and that's all included in the docker image. Only thing I can really think of is .next folders are in the gitignore, and maybe docker excludes them because of that. I'm not very good with docker so this has me stumped.
JustJake
JustJake•2y ago
it should only ignore dockerignore stuff Does turbo come with a production webserver even? Ah the answer is "no" sec
Tanner Scadden
Tanner Scadden•2y ago
I logged out each folder's layer after the build is complete and the .next folder is missing. Trying a custom buildpath to see if that fixes it Setting a custom buildpath in nextconfig works. I changed the folder to be /dist and it runs now. Changing the folder name to be .dist to see if that breaks it.
JustJake
JustJake•2y ago
Huh Nice 😄
Tanner Scadden
Tanner Scadden•2y ago
.dist doesn't show when I log out the file structure but it runs. Not sure what exactly happened or why it's working again. My project ID is at the top if your team ever wants to look into my build history and try to figure it out. Thanks for your time @Cooper! Enjoy your night 🙂
JustJake
JustJake•2y ago
All good and glad you're sorted! Maybe that engineer will have a look tomorrow lol
Tanner Scadden
Tanner Scadden•2y ago
Spoke too soon. /.dist doesn't work, but /dist does. Looks like it doesn't like build folders that start with "." Gl with this bug!
Could not find a production build in the '/app/apps/app/.dist' directory.
Could not find a production build in the '/app/apps/app/.dist' directory.
jr
jr•2y ago
Hello, I am available now to take a look at what went wrong. Just to recap - It is building and deploying as expected now? - The issue was that the path was not relative to the current directory?
Tanner Scadden
Tanner Scadden•2y ago
It is building and deploying now! Issue seems to be if the folder name starts with "." It is missing even right after building.
jr
jr•2y ago
Interesting. Thanks for reporting