Trying to build and deploy (same image) in two separate steps

Hi

I want to build an image from a Dockerfile remotely (local machine is an M1) and deploy that same image in two separate steps, a few minutes apart.
Step one is to build image remotely using a Fly builder and tag/label the image.

flyctl deploy --build-only --remote-only  --image-label "registry.fly.io/damp-bird-1849:deployment-12345"

Then, later in my CD pipeline I want to deploy that same image. I tried:

flyctl deploy --image "registry.fly.io/damp-bird-1849:deployment-12345"

but I get the following error:

==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'registry.fly.io/damp-bird-1849:12345' locally...
Searching for image 'registry.fly.io/damp-bird-1849:12345' remotely...
Error failed to fetch an image or build from source: Could not find image "registry.fly.io/damp-bird-1849:12345"

I was expecting the image to be available in the fly registry. What am I doing wrong?

Thank you.

Hey, I tried to replicate your error and got stuck at the same place, but the steps mentioned below helped me unblock, not sure if this is what you are looking for but it kinda worked, let me know how it goes and there might be a better solution.

cheers!

oops, this only works for local build

Hey Diru

Thank you for your response. When I do a local build with docker (on M1 Macbook) and then push to the fly registry, it complains due to the architecture mismatch:

Error Validation failed: Image must be amd64 architecture for linux us

I’ll give this a try with GitHub Actions.

Cheers!

I don’t think --build-only pushes the image. It just builds it. I made a feature request for you here: allow fly deploy --build-only to push an image · Issue #873 · superfly/flyctl · GitHub

If/when it does push, it’ll work.--image-label only takes the label, not the full image URL:

flyctl deploy --build-only --remote-only --image-label "deployment-12345"
flyctl deploy --image "registry.fly.io/damp-bird-1849:deployment-12345"
1 Like

Hey Kurt

Thanks for the response and the correct use of the --image-label option. If I understand it correctly, even the --remote-only build doesn’t push to the registry.
I believe @diru is going to work on the feature request for this. :+1:

Cheers