Unable to run nextjs following the instructions

Hello,

I followed this guide:

and used the

npx dockerfile

to create the dockerfile and it also creates docker-entrypoint.js.

however, after fly deploy I get this error:
ERROR Error: failed to spawn command: /app/docker-entrypoint.js node server.js: No such file or directory (os error 2)

When I try to relocate it into the app folder, I get these errors:

	2025-01-27 11:49:40.125	
Machine started in 1.277s
	
	
2025-01-27 11:49:40.079	
 INFO [fly api proxy] listening at /.fly/api
	
	
2025-01-27 11:49:40.070	
 INFO Preparing to run: `/app/docker-entrypoint.js node server.js` as root
	
	
2025-01-27 11:49:39.895	
 INFO Starting init (commit: 3a6e10d0)...
	
	
2025-01-27 11:49:38.920	
2025-01-27T09:49:38.920819533 [01JJKJKTVFS595S4MBDQR4N28F:main] Running Firecracker v1.7.0
	
	
2025-01-27 11:49:36.890	
[    3.142007] reboot: Restarting system
	
	
2025-01-27 11:49:36.889	
 WARN could not unmount /rootfs: EINVAL: Invalid argument
	
	
2025-01-27 11:49:36.834	
 INFO Starting clean up.
	
	
2025-01-27 11:49:36.817	
 INFO Main child exited normally with code: 1
	
	
2025-01-27 11:49:36.020	
Node.js v23.6.0
	
	
2025-01-27 11:49:36.020	
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
	
	
2025-01-27 11:49:36.020	
at ChildProcess.emit (node:events:507:28)
	
	
2025-01-27 11:49:36.020	
at ChildProcess.<anonymous> (/app/docker-entrypoint.js:24:16)
	
	
2025-01-27 11:49:36.020	
Error: npx next build --experimental-build-mode generate failed rc=127
	
	
2025-01-27 11:49:36.020	
^
	
	
2025-01-27 11:49:36.020	
reject(new Error(`${command} failed rc=${code}`))
	
	
2025-01-27 11:49:36.020	
/app/docker-entrypoint.js:24
	
	
2025-01-27 11:49:36.000	
sh: 1: next: not found
	
	
2025-01-27 11:49:35.281	
2025/01/27 09:49:35 INFO SSH listening listen_address=[fdaa:e:3266:a7b:1c3:efb0:3a8:2]:22 dns_server=[fdaa::3]:53
	
	
2025-01-27 11:49:35.277	
waiting for machine to be reachable on 0.0.0.0:3000 (waited 5.540917568s so far)
	
	
2025-01-27 11:49:34.861	
Machine started in 1.273s
	
	
2025-01-27 11:49:34.817	
 INFO [fly api proxy] listening at /.fly/api
	
	
2025-01-27 11:49:34.807	
 INFO Preparing to run: `/app/docker-entrypoint.js node server.js` as root
	
	
2025-01-27 11:49:34.654	
 INFO Starting init (commit: 3a6e10d0)...
	
	
2025-01-27 11:49:33.668	
2025-01-27T09:49:33.668356107 [01JJKJKTVFS595S4MBDQR4N28F:main] Running Firecracker v1.7.0
	
	
2025-01-27 11:49:31.763	
[    3.162953] reboot: Restarting system
	
	
2025-01-27 11:49:31.763	
 WARN could not unmount /rootfs: EINVAL: Invalid argument
	
	
2025-01-27 11:49:31.712	
 INFO Starting clean up.
	
	
2025-01-27 11:49:31.695	
 INFO Main child exited normally with code: 1
	
	
2025-01-27 11:49:30.946	
Node.js v23.6.0
	
	
2025-01-27 11:49:30.946	
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
	
	
2025-01-27 11:49:30.946	
at ChildProcess.emit (node:events:507:28)
	
	
2025-01-27 11:49:30.946	
at ChildProcess.<anonymous> (/app/docker-entrypoint.js:24:16)
	
	
2025-01-27 11:49:30.946	
Error: npx next build --experimental-build-mode generate failed rc=127
	
	
2025-01-27 11:49:30.946	
^
	
	
2025-01-27 11:49:30.946	
reject(new Error(`${command} failed rc=${code}`))
	
	
2025-01-27 11:49:30.946	
/app/docker-entrypoint.js:24
	
	
2025-01-27 11:49:30.925	
sh: 1: next: not found
	
	
2025-01-27 11:49:30.135	
2025/01/27 09:49:30 INFO SSH listening listen_address=[fdaa:e:3266:a7b:1c3:efb0:3a8:2]:22 dns_server=[fdaa::3]:53
	
	
2025-01-27 11:49:29.736	
machine started in 1.30769687s
	
	
2025-01-27 11:49:29.735	
Machine started in 1.301s
	
	
2025-01-27 11:49:29.695	
 INFO [fly api proxy] listening at /.fly/api
	
	
2025-01-27 11:49:29.684	
 INFO Preparing to run: `/app/docker-entrypoint.js node server.js` as root
	
	
2025-01-27 11:49:29.531	
 INFO Starting init (commit: 3a6e10d0)...
	
	
2025-01-27 11:49:28.516	
2025-01-27T09:49:28.516549348 [01JJKJKTVFS595S4MBDQR4N28F:main] Running Firecracker v1.7.0
	
	
2025-01-27 11:49:28.429	
Starting machine

Iā€™m a bit unsure how to debug this, considering I just followed the guide

edit:

Checking from local build process running the image throws.
sh: 1: next: not found
/app/docker-entrypoint.js:24
        reject(new Error(`${command} failed rc=${code}`))
               ^

Error: npx next build --experimental-build-mode generate failed rc=127
    at ChildProcess.<anonymous> (/app/docker-entrypoint.js:24:16)
    at ChildProcess.emit (node:events:507:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

Node.js v23.6.0

This does not seem too good

just if someone else faces same issue, it seems that the entrypoint is just doing some duplicate logic.

I changed the entry point to

Set environment variables

ENV PORT=3000

ENV HOSTNAME=ā€œ0.0.0.0ā€

and deleted ENTRYPOINT and the file and now it works.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.