How to rollback a fly.io deploy

#devops #fly.io

One of the most important workflows in the DevOps world is the rollback of a bad deploy. I recently found out that this is not currently possible on Fly.io directly with their CLI or on the website.

Note: no dig on Fly, they’re still new, and are a great service

However, after some (slightly stressful) research I learned that you can redeploy images from the fly docker registry.

# find all 
〉 fly releases --image                                                                                  
VERSION STATUS          DESCRIPTION     USER                    DATE                    DOCKER IMAGE

v189    complete        Release         [email protected]        May 02 2024 00:34       registry.fly.io/yourproject:main-12345abcdefg
v188    complete        Release         [email protected]        May 01 2024 03:14       registry.fly.io/yourproject:main-2345abcdefg1
...

In our example v189 is the bad deploy, and I want to rollback to v188.

To do this, I’ll need to tell fly which docker image to deploy. For that I’ll need the docker image associated with v188 (registry.fly.io/yourproject:main-2345abcdefg1 in this example)

Then I can deploy by including the --image flag

# redeploy the last good image
〉 fly deploy --image registry.fly.io/yourproject:main-2345abcdefg1

Read more: https://community.fly.io/t/how-to-do-rollback-releases-3-different-ways/16347