failed to fetch an image or build from source: error building: failed to solve: exit code: 2

Trying to deploy my Next.JS app, which in the past deployed just fine.

==> Building image with Depot   
--> build:  (​)
[+] Building 7.0s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.3s
 => => transferring dockerfile: 1.09kB                                                                                                                                                                                       0.3s 
 => resolve image config for docker-image://docker.io/docker/dockerfile:1                                                                                                                                                    3.5s
 => docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                                     0.5s
 => => resolve docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                                         0.0s 
 => => sha256:1e45ed8b8be3fcf5baec105c530196be8d0b853893e209e4adf6c0e925079ff0 12.49MB / 12.49MB                                                                                                                             0.4s
 => => extracting sha256:1e45ed8b8be3fcf5baec105c530196be8d0b853893e209e4adf6c0e925079ff0                                                                                                                                    0.1s
 => [internal] load metadata for docker.io/library/node:23-slim                                                                                                                                                              1.7s
 => [internal] load .dockerignore                                                                                                                                                                                            0.3s
 => => transferring context: 514B                                                                                                                                                                                            0.3s 
==> Building image
Waiting for depot builder...
Waiting for depot builder...    
Waiting for depot builder...    
Waiting for depot builder...    
Waiting for depot builder...    
==> Building image with Depot   
--> build:  (​)
[+] Building 1.2s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.2s
 => => transferring dockerfile: 1.09kB                                                                                                                                                                                       0.2s 
 => resolve image config for docker-image://docker.io/docker/dockerfile:1                                                                                                                                                    0.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                              0.0s
 => => resolve docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                                         0.0s 
 => [internal] load metadata for docker.io/library/node:23-slim                                                                                                                                                              0.3s 
 => [internal] load .dockerignore                                                                                                                                                                                            0.2s
 => => transferring context: 514B                                                                                                                                                                                            0.2s 
Error: failed to fetch an image or build from source: error building: failed to solve: exit code: 2
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=23
FROM node:23-slim as base

LABEL fly_launch_runtime="Next.js"

# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"
ARG YARN_VERSION=1.22.19

# Install Yarn 3
RUN corepack enable && \
  yarn set version ${YARN_VERSION}

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
  apt-get install -y build-essential pkg-config python-is-python3

# Install node modules
COPY --link package.json tsconfig.json next.config.js yarn.lock .yarnrc.yml ./
RUN yarn install --immutable --production=false

# Copy application code
COPY --link . .

# Build application
RUN yarn run build

# Remove development dependencies
RUN yarn install


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "yarn", "run", "start" ]
# fly.toml app configuration file generated for sunway-bcc on 2024-05-02T10:01:29+08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'sunway-bcc'
primary_region = 'sin'

[build]

[env]
  NEXT_PUBLIC_ALCHEMY_ID = <REDACTED>

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 512

Not just you, I think they broke flyctl. It won’t deploy from source code that I haven’t touched since I last deployed.

Hopefully they fix this, because it’s annoying.

Does --depot=false help, guys?

https://community.fly.io/t/depot-builder-outage-and-workaround/22485

Added builders

@mayailurus testing it right now

Edit: Nope, doesn’t help. I need to get this up urgently, is there an alternative?

@cjwtx thinks it might be a problem with flyctl, in which case downgrading might help.

Sorry to hear that you’re in a bind, :adhesive_bandage:

No change

Maybe post your logs as well, for comparison.

Are you also seeing it fail during transferring context, for example?

Waiting for remote builder fly-builder-falling-tree-8937...
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Remote builder fly-builder-falling-tree-8937 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 5.0s (5/5) FINISHED
 => [internal] load .dockerignore                                                                                                                                                                                            0.2s
 => => transferring context: 514B                                                                                                                                                                                            0.2s 
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.2s 
 => => transferring dockerfile: 1.09kB                                                                                                                                                                                       0.2s 
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                                   1.8s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                              0.0s
 => [internal] load metadata for docker.io/library/node:23-slim                                                                                                                                                              2.8s
==> Building image
✓ compatible remote builder found
INFO Override builder host with: https://fly-builder-falling-tree-8937.fly.dev (was tcp://[fdaa:1:d577:a7b:1d7:b843:cf06:2]:2375)

Waiting for remote builder fly-builder-falling-tree-8937...
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Remote builder fly-builder-falling-tree-8937 ready
INFO Override builder host with: https://fly-builder-falling-tree-8937.fly.dev (was tcp://[fdaa:1:d577:a7b:1d7:b843:cf06:2]:2375)

Waiting for remote builder fly-builder-falling-tree-8937...
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Waiting for remote builder fly-builder-falling-tree-8937...    
Remote builder fly-builder-falling-tree-8937 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 2.2s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.1s
 => => transferring dockerfile: 1.09kB                                                                                                                                                                                       0.1s 
 => [internal] load .dockerignore                                                                                                                                                                                            0.2s 
 => => transferring context: 514B                                                                                                                                                                                            0.2s 
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                                   1.4s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5                                                                                              0.0s
 => [internal] load metadata for docker.io/library/node:23-slim                                                                                                                                                              0.5s 
Error: failed to fetch an image or build from source: error building: failed to solve: exit code: 2

How does one downgrade flyctl

This looks like the procedure on Linux, although I haven’t tried this myself:

https://community.fly.io/t/blocked-on-deploying-after-upgrading-flyctl/13422/7

(You may need to disable auto-upgrades first, these days.)


With brew, I don’t know…

Downgraded all the way back to v.0.2.X and it still throws the same error

Hm… I just tried myself with v0.1.141, deploying to ewr & building in ord, and didn’t see any problems…

That’s way in the past, though, so it’s not necessarily the core problem.

Your second set of logs shows what look like intermittent failures or network glitches… How long do those Waiting for remote builder messages last, for example? (I only saw that for a couple seconds.)

They barely last miliseconds, I assume its just my powershell, doesn’t seem like a network issue.

Downgraded all the way to your version, doesn’t work.

I’m also using Singapore

I think I’d suggest trying with a minimal application now. (One that only does sleep inf or the like as its CMD.) If even that fails, then I believe there’s an undocumented environment variable that would allow you to move your builder all the way over to ord or syd, although I don’t recall the details…

FROM debian:bullseye-slim

CMD ["sleep", "inf"]

(That’s the Dockerfile I was just testing with myself.)

Works fine, it only seems to be my current project. I was able to deploy a nodejs project.

Strange… The original project never seems to make much progress… If it had gotten farther along, e.g., to yarn install, I would suspect OOM.

It might still be worth checking the builder machine’s own, separate logs: fly apps list and then fly logs -a fly-builder-<random-suffix>.

On Linux, there is the third option of building with a local Docker daemon and then uploading the resulting image to Fly’s internal registry, if you have an unmetered and fast network connection. But I don’t know how well that really works on native Windows.

(WSL2 might also be a possibility, although it’s not clear to me how much effort that one would be.)

You can clone a build machine into a new region, destroy the original, and then run fly deploy --depot=false

1 Like