NextJS deploy fails with "Error failed to fetch an image or build from source: executing lifecycle: failed with status code: 51"

Hi, I’m trying to deploy a NextJS app. I’ve deployed it a few times but now consistently get the following error. How can I debug this?
I’m running flyctl deploy --verbose. I have a fly.toml and .dockerignore file; Fly is generating the docker file. On an M1 Macbook Pro.


info  - Loaded env from /workspace/.env.local
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

info  - Checking validity of types...
warn  - No ESLint configuration detected. Run next lint to begin setup
info  - Creating an optimized production build...
warn  - using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware
info  - Compiled successfully
info  - Collecting page data...
Killed
ERROR: failed to build: exit status 137
Error failed to fetch an image or build from source: executing lifecycle: failed with status code: 51

Oh, I just realize it works with flyctl deploy --remote-only.

So I think the issue is:

  • Docker doesn’t work well (or at all?) on an M1 Mac when targeting x86
  • I installed Docker on my laptop since the last deploy. flyctl saw the daemon and switched my build mode to local without me realizing it.

Is that right? Would be helpful if flyctl detected this condition and at least warned the user that it’s not a stable build profile.

You are correct.

Docker has issues on an M1:

Yep, I believe fly defaults to using local Docker if it’s available. And so that experience makes sense: once you added Docker locally, fly CLI noticed, and so used it. Until you said explicitly not to, by adding the --remote-only flag.

As for whether fly should detect it is running on an M1 (and so recommend using the remote builder instead) I agree that would be a nice improvement to avoid that issue.

1 Like